1
0
mirror of https://github.com/mainflux/mainflux.git synced 2025-04-26 13:48:53 +08:00

27 lines
581 B
Go

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
}