pub trait ClockSequence {
type Output;
// Required method
fn generate_sequence(&self, seconds: u64, subsec_nanos: u32) -> Self::Output;
// Provided methods
fn generate_timestamp_sequence(
&self,
seconds: u64,
subsec_nanos: u32
) -> (Self::Output, u64, u32) { ... }
fn usable_bits(&self) -> usize
where Self::Output: Sized { ... }
}
Expand description
A counter that can be used by versions 1 and 6 UUIDs to support the uniqueness of timestamps.
§References
Required Associated Types§
Required Methods§
sourcefn generate_sequence(&self, seconds: u64, subsec_nanos: u32) -> Self::Output
fn generate_sequence(&self, seconds: u64, subsec_nanos: u32) -> Self::Output
Get the next value in the sequence to feed into a timestamp.
This method will be called each time a Timestamp
is constructed.
Any bits beyond ClockSequence::usable_bits
in the output must be unset.
Provided Methods§
sourcefn generate_timestamp_sequence(
&self,
seconds: u64,
subsec_nanos: u32
) -> (Self::Output, u64, u32)
fn generate_timestamp_sequence( &self, seconds: u64, subsec_nanos: u32 ) -> (Self::Output, u64, u32)
Get the next value in the sequence, potentially also adjusting the timestamp.
This method should be preferred over generate_sequence
.
Any bits beyond ClockSequence::usable_bits
in the output must be unset.
sourcefn usable_bits(&self) -> usize
fn usable_bits(&self) -> usize
The number of usable bits from the least significant bit in the result of ClockSequence::generate_sequence
or ClockSequence::generate_timestamp_sequence
.
The number of usable bits must not exceed 128.
The number of usable bits is not expected to change between calls. An implementation of ClockSequence
should
always return the same value from this method.