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 = u16>) -> Timestamp
pub fn now(context: impl ClockSequence<Output = u16>) -> Timestamp
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) -> Timestamp
pub const fn from_rfc4122(ticks: u64, counter: u16) -> Timestamp
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
) -> Timestamp
pub fn from_unix( context: impl ClockSequence<Output = u16>, seconds: u64, nanos: u32 ) -> Timestamp
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.
Trait Implementations§
source§impl PartialEq<Timestamp> for Timestamp
impl PartialEq<Timestamp> for Timestamp
impl Copy for Timestamp
impl Eq for Timestamp
impl StructuralEq for Timestamp
impl StructuralPartialEq for Timestamp
Auto Trait Implementations§
impl RefUnwindSafe for Timestamp
impl Send for Timestamp
impl Sync for Timestamp
impl Unpin for Timestamp
impl UnwindSafe for Timestamp
Blanket Implementations§
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.