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
sourceimpl Timestamp
impl Timestamp
sourcepub fn now(context: impl ClockSequence<Output = u16>) -> Self
pub fn now(context: impl ClockSequence<Output = u16>) -> Self
Get a timestamp representing the current system time.
This method defers to the standard library’s SystemTime
type.
Panics
This method will panic if calculating the elapsed time since the Unix epoch fails.
sourcepub const fn from_rfc4122(ticks: u64, counter: u16) -> Self
pub const fn from_rfc4122(ticks: u64, counter: u16) -> Self
Construct a Timestamp
from an RFC4122 timestamp and counter, as used
in versions 1 and 6 UUIDs.
sourcepub fn from_unix(
context: impl ClockSequence<Output = u16>,
seconds: u64,
nanos: u32
) -> Self
pub fn from_unix(
context: impl ClockSequence<Output = u16>,
seconds: u64,
nanos: u32
) -> Self
Construct a Timestamp
from a Unix timestamp, as used in version 7 UUIDs.
sourcepub const fn to_unix(&self) -> (u64, u32)
pub const fn to_unix(&self) -> (u64, u32)
Get the value of the timestamp as a Unix timestamp, as used in version 7 UUIDs.
sourcepub const fn to_unix_nanos(&self) -> u32
👎Deprecated: use to_unix
instead
pub const fn to_unix_nanos(&self) -> u32
to_unix
insteadGet the number of fractional nanoseconds in the Unix timestamp.
This method is deprecated and probably doesn’t do what you’re expecting it to. It doesn’t return the timestamp as nanoseconds since the Unix epoch, it returns the fractional seconds of the timestamp.