pub struct Timestamp(/* private fields */);Expand description
Strictly monotonic timestamp since SystemTime::UNIX_EPOCH in microseconds.
The purpose of this timestamp is to unique per “user”, not globally,
it achieves this by:
1. Override the last byte with a random clock_id, reducing the probability
of two matching timestamps across multiple machines/threads.
2. Guarantee that the remaining 3 bytes are ever increasing (strictly monotonic) within
the same thread regardless of the wall clock value
This timestamp is also serialized as BE bytes to remain sortable.
If a utf-8 encoding is necessary, it is encoded as base32::Alphabet::Crockford
to act as a sortable Id.
Implementations§
Trait Implementations§
Source§impl AddAssign<u64> for Timestamp
impl AddAssign<u64> for Timestamp
Source§fn add_assign(&mut self, other: u64)
fn add_assign(&mut self, other: u64)
Performs the
+= operation. Read moreSource§impl AddAssign for Timestamp
impl AddAssign for Timestamp
Source§fn add_assign(&mut self, other: Timestamp)
fn add_assign(&mut self, other: Timestamp)
Performs the
+= operation. Read moreSource§impl<'de> Deserialize<'de> for Timestamp
Available on crate feature serde only.
impl<'de> Deserialize<'de> for Timestamp
Available on crate feature
serde only.Source§fn deserialize<D>(
deserializer: D,
) -> Result<Timestamp, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Timestamp, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<SystemTime> for Timestamp
impl From<SystemTime> for Timestamp
Source§fn from(system_time: SystemTime) -> Timestamp
fn from(system_time: SystemTime) -> Timestamp
Converts to this type from the input type.
Source§impl Ord for Timestamp
impl Ord for Timestamp
Source§impl PartialOrd for Timestamp
impl PartialOrd for Timestamp
Source§impl Serialize for Timestamp
Available on crate feature serde only.
impl Serialize for Timestamp
Available on crate feature
serde only.Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
Source§impl SubAssign<u64> for Timestamp
impl SubAssign<u64> for Timestamp
Source§fn sub_assign(&mut self, other: u64)
fn sub_assign(&mut self, other: u64)
Performs the
-= operation. Read moreSource§impl SubAssign for Timestamp
impl SubAssign for Timestamp
Source§fn sub_assign(&mut self, other: Timestamp)
fn sub_assign(&mut self, other: Timestamp)
Performs the
-= operation. Read moreimpl 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 UnsafeUnpin 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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.