pub struct Timestamp { /* private fields */ }
Expand description
A timestamp that can be encoded into a UUID.
This type abstracts the specific encoding, so versions 1, 6, and 7 UUIDs can both be supported through the same type, even though they have a different representation of a timestamp.
§References
Implementations§
Source§impl Timestamp
impl Timestamp
Sourcepub fn now(context: impl ClockSequence<Output = impl Into<u128>>) -> Self
pub fn now(context: impl ClockSequence<Output = impl Into<u128>>) -> Self
Get a timestamp representing the current system time and up to a 128-bit counter.
This method defers to the standard library’s SystemTime
type.
Sourcepub const fn from_gregorian(ticks: u64, counter: u16) -> Self
pub const fn from_gregorian(ticks: u64, counter: u16) -> Self
Construct a Timestamp
from the number of 100 nanosecond ticks since 00:00:00.00,
15 October 1582 (the date of Gregorian reform to the Christian calendar) and a 14-bit
counter, as used in versions 1 and 6 UUIDs.
§Overflow
If conversion from RFC 9562 ticks to the internal timestamp format would overflow it will wrap.
Sourcepub const fn from_unix_time(
seconds: u64,
subsec_nanos: u32,
counter: u128,
usable_counter_bits: u8,
) -> Self
pub const fn from_unix_time( seconds: u64, subsec_nanos: u32, counter: u128, usable_counter_bits: u8, ) -> Self
Construct a Timestamp
from a Unix timestamp and up to a 128-bit counter, as used in version 7 UUIDs.
Sourcepub fn from_unix(
context: impl ClockSequence<Output = impl Into<u128>>,
seconds: u64,
subsec_nanos: u32,
) -> Self
pub fn from_unix( context: impl ClockSequence<Output = impl Into<u128>>, seconds: u64, subsec_nanos: u32, ) -> Self
Construct a Timestamp
from a Unix timestamp and up to a 128-bit counter, as used in version 7 UUIDs.
Sourcepub const fn to_gregorian(&self) -> (u64, u16)
pub const fn to_gregorian(&self) -> (u64, u16)
Get the value of the timestamp as the number of 100 nanosecond ticks since 00:00:00.00, 15 October 1582 and a 14-bit counter, as used in versions 1 and 6 UUIDs.
§Overflow
If conversion from the internal timestamp format to ticks would overflow then it will wrap.
If the internal counter is wider than 14 bits then it will be truncated to 14 bits.