pub struct ContextV1 { /* private fields */ }Expand description
An internally synchronized, wrapping counter that produces 14-bit values for version 1 and version 6 UUIDs.
This type is:
- Non-reseeding: The counter is not reseeded on each time interval (100ns).
- Non-adjusting: The timestamp is not incremented when the counter wraps within a time interval (100ns).
- Thread-safe: The underlying counter is atomic, so can be shared across threads.
This type should be used when constructing versions 1 and 6 UUIDs.
This type should not be used when constructing version 7 UUIDs. When used to construct a version 7 UUID, the 14-bit counter will be padded with random data. Counter overflows are more likely with a 14-bit counter than they are with a 42-bit counter when working at millisecond precision. This type doesn’t attempt to adjust the timestamp on overflow.
Implementations§
Source§impl ContextV1
impl ContextV1
Sourcepub const fn new(count: u16) -> Self
pub const fn new(count: u16) -> Self
Construct a new context that’s initialized with the given value.
The starting value should be a random number, so that UUIDs from
different systems with the same timestamps are less likely to collide.
When the rng feature is enabled, prefer the ContextV1::new_random method.
Sourcepub fn new_random() -> Self
pub fn new_random() -> Self
Construct a new context that’s initialized with a random value.
Trait Implementations§
Source§impl ClockSequence for ContextV1
impl ClockSequence for ContextV1
Source§fn generate_sequence(&self, _seconds: u64, _nanos: u32) -> Self::Output
fn generate_sequence(&self, _seconds: u64, _nanos: u32) -> Self::Output
Source§fn usable_bits(&self) -> usize
fn usable_bits(&self) -> usize
ClockSequence::generate_sequence
or ClockSequence::generate_timestamp_sequence. Read more