pub struct Timestamp(/* private fields */);Expand description
A pkarr timestamp in microseconds since the UNIX epoch.
Used as the seq field in BEP_0044 DHT mutable items. Per the spec, a new
publish must have a strictly higher timestamp than the previous one, or DHT
nodes will reject the update.
Timestamp::now is guaranteed to be strictly monotonic: it will never
return the same value twice and will never go backward, even if the system
clock is corrected by NTP. This is achieved by tracking the last returned
value and ensuring each call returns at least last + 1.
Implementations§
Source§impl Timestamp
impl Timestamp
Sourcepub fn now() -> Self
pub fn now() -> Self
Returns a strictly monotonic timestamp.
Guaranteed to return a value greater than any previous call, even if the system clock jumps backward (e.g. due to NTP correction).
Sourcepub fn from_micros(micros: u64) -> Self
pub fn from_micros(micros: u64) -> Self
Creates a timestamp from a raw microseconds value.
Sourcepub fn to_be_bytes(self) -> [u8; 8]
pub fn to_be_bytes(self) -> [u8; 8]
Returns the big-endian byte representation.
Sourcepub fn from_be_bytes(bytes: [u8; 8]) -> Self
pub fn from_be_bytes(bytes: [u8; 8]) -> Self
Parses from big-endian bytes.
Trait Implementations§
Source§impl Ord for Timestamp
impl Ord for Timestamp
Source§impl PartialOrd for Timestamp
impl PartialOrd 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: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§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.