pub struct Timestamp {
seconds: u64,
subsec_nanos: u32,
counter: u128,
usable_counter_bits: u8,
}
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
Fields§
§seconds: u64
§subsec_nanos: u32
§counter: u128
§usable_counter_bits: u8
Implementations§
source§impl Timestamp
impl Timestamp
sourcepub fn now(context: impl ClockSequence<Output = impl Into<u128>>) -> Timestamp
pub fn now(context: impl ClockSequence<Output = impl Into<u128>>) -> Timestamp
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) -> Timestamp
pub const fn from_gregorian(ticks: u64, counter: u16) -> Timestamp
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
) -> Timestamp
pub const fn from_unix_time( seconds: u64, subsec_nanos: u32, counter: u128, usable_counter_bits: u8 ) -> Timestamp
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
) -> Timestamp
pub fn from_unix( context: impl ClockSequence<Output = impl Into<u128>>, seconds: u64, subsec_nanos: u32 ) -> Timestamp
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.
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>
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.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.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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 moresource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request