Expand description
Provides a convenient abstraction for working with identifiers of various types.
The main use case of this crate is to define your own “identifier domains” (categories of
things that can be identified) using the IdDomain trait. IdDomain can be implemented for
almost any type or even just a marker struct if you don’t have relevant type available already.
To implement IdDomain you provide a Backing type that will be used to store the actual
identifier type of your choice. You can then use Id<T> to construct identifiers of that
type, scoped to the domain you have defined. The generic argument acts as a compile-time check
that you are not mixing up identifiable domains and helps clarify the intent between
identifiers with minimal boilerplate.
Other minor features include:
- Providing random generation of identifiers in your domain
- Providing a const representation of identifiers in your domain
- Extracting identifiers of types using the
IdentifyAstrait - Assigning identifiers to types using the
StableTypeIdtrait
§Optional features
Structs§
- Id
- A container type for an unique identifier of an object in domain
D.
Traits§
- Generate
IdStateful - Allows a type to generate identifiers in a ‘stateful’ manner.
- Generate
IdStateless - Allows a type to generate identifiers in a ‘stateless’ manner.
- IdDomain
- Defines a “domain” of identifiable entities.
- Identify
As - Used to identify
Selfby some identifier in domainD. - Stable
Type Id - This trait lets you define stable identifiers of a specified
IdDomainfor types. The implementor gets to choose their own identifier that is assumed to be unique.