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
Available on crate feature serde only.
impl<'de> Deserialize<'de> for Timestamp
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>,
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
Available on crate feature serde only.
impl Serialize for Timestamp
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,
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 more