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.
§Overflow
If conversion from RFC4122 ticks to the internal timestamp format would overflow it will wrap.
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.
§Overflow
If conversion from RFC4122 ticks to the internal timestamp format would overflow it will wrap.
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.
§Overflow
If conversion from RFC4122 ticks to the internal timestamp format would overflow it will wrap.
sourcepub const fn to_unix_nanos(&self) -> u32
👎Deprecated: use to_unix
instead; this method will be removed in a future release
pub const fn to_unix_nanos(&self) -> u32
to_unix
instead; this method will be removed in a future releaseGet 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 for Timestamp
impl PartialEq for Timestamp
impl Copy for Timestamp
impl Eq for Timestamp
impl StructuralPartialEq for Timestamp
Auto Trait Implementations§
impl Freeze for Timestamp
impl RefUnwindSafe for Timestamp
impl Send for Timestamp
impl Sync for Timestamp
impl Unpin for Timestamp
impl UnwindSafe for Timestamp
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more