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.
U64 (through pubky) of microseconds is valid for the next ~600 thousand years! i64 (in mainline) of microseconds is valid for the next ~300 thousand years!
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)
+= 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)
+= operation. Read moreSource§impl<'de> Deserialize<'de> for Timestamp
impl<'de> Deserialize<'de> for Timestamp
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>,
Source§impl From<SystemTime> for Timestamp
impl From<SystemTime> for Timestamp
Source§fn from(system_time: SystemTime) -> Timestamp
fn from(system_time: SystemTime) -> Timestamp
Source§impl Ord for Timestamp
impl Ord for Timestamp
Source§impl PartialOrd for Timestamp
impl PartialOrd for Timestamp
Source§impl Serialize for Timestamp
impl Serialize for Timestamp
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,
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)
-= 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)
-= 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 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: 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.