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.
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> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)