[−][src]Crate unique_id
A trait and implementations for unique ID generators.
This crate provides a very simple trait, Generator
, that will return successive unique identifiers. Two
implementations of this trait are provided which provide unique string and integer values respectively.
Example
The following shows an example of the StringGenerator
implementation.
use unique_id::Generator; use unique_id::string::StringGenerator; let gen = StringGenerator::default(); let mut last = gen.next_id(); for _ in 1..100_000 { let next = gen.next_id(); assert_ne!(last, next); last = next; }
Modules
random | An implementation that provides random 128-bit unsigned integer values. |
sequence | An implementation that provides monotonically increasing integer values. |
string | An implementation that provides unique string values. |
Traits
Generator | The primary ID generator trait, it provides for generating a new ID with |
GeneratorFromSeed | While it is required for a generator to support the |
GeneratorFromStr | If the type |
GeneratorWithInvalid | For generators that are able to reserve a unique value that is not valid as an ID. |