mirror of
https://github.com/mainflux/mainflux.git
synced 2025-04-27 13:48:49 +08:00

* MF-325 - Add SPDX license and copyright headers Signed-off-by: Ivan Milošević <iva@blokovi.com> * MF-325 - Add SPDX license and copyright headers Signed-off-by: Ivan Milošević <iva@blokovi.com> * MF-325 - Add SPDX license and copyright headers Signed-off-by: Ivan Milošević <iva@blokovi.com> * MF-325 - Add SPDX license and copyright headers Signed-off-by: Ivan Milošević <iva@blokovi.com> * MF-325 - Change mainflux version from 0.4.0 to 0.5.0 Signed-off-by: Ivan Milošević <iva@blokovi.com>
41 lines
747 B
Go
41 lines
747 B
Go
//
|
|
// Copyright (c) 2018
|
|
// Mainflux
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
|
|
//
|
|
// Copyright (c) 2018
|
|
// Mainflux
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
|
|
package things
|
|
|
|
import (
|
|
"strconv"
|
|
)
|
|
|
|
// IdentityProvider specifies an API for generating unique identifiers.
|
|
type IdentityProvider interface {
|
|
// ID generates the unique identifier.
|
|
ID() string
|
|
}
|
|
|
|
// FromString extracts an unsigned integer from given string value. Since
|
|
// unsigned integers are used for thing and channel identifiers, malformed
|
|
// extraction will result in ErrNotFound error.
|
|
func FromString(v string) (uint64, error) {
|
|
base := 10
|
|
bitSize := 64
|
|
|
|
id, err := strconv.ParseUint(v, base, bitSize)
|
|
if err != nil {
|
|
return 0, ErrNotFound
|
|
}
|
|
|
|
return id, nil
|
|
}
|