Documentation
¶
Overview ¶
Package identifier provides a unified interface for generating and validating unique identifiers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Generator ¶
type Generator[T ~int64 | ~string] interface { Identifier // Generate creates a new identifier of type T. Generate() T // Validate checks if the provided value is a valid identifier of type T. Validate(T) bool }
Generator defines a unified, generic interface for generating identifiers of a specific type. This is the interface that consuming code will typically interact with after initialization.
type Identifier ¶
type Identifier interface {
Name() string // Name returns the name of the identifier.
Size() int // Size returns the size of the identifier in bits.
}
Identifier defines the basic interface for all identifier types.
type Provider ¶
type Provider interface {
Identifier
// AsString returns a string-based generator. Returns nil if not supported.
AsString() Generator[string]
// AsNumber returns a number-based generator. Returns nil if not supported.
AsNumber() Generator[int64]
}
Provider is an interface for an algorithm that can provide generators for different types. A single provider can vend either a string or a number generator, or both.
Click to show internal directories.
Click to hide internal directories.