pub struct HlcTimestamp {
pub physical: u64,
pub logical: u32,
}Expand description
Fields§
§physical: u64Wall-clock component: nanoseconds since the Unix epoch.
logical: u32Logical counter: incremented when the physical component is tied.
Implementations§
Source§impl HlcTimestamp
impl HlcTimestamp
Sourcepub fn happened_before(self, other: HlcTimestamp) -> bool
pub fn happened_before(self, other: HlcTimestamp) -> bool
Returns true if self causally happened before other.
Equivalent to self < other.
Sourcepub fn concurrent_with(self, other: HlcTimestamp) -> bool
pub fn concurrent_with(self, other: HlcTimestamp) -> bool
Returns true if self and other are concurrent, i.e. neither
happened before the other.
In HLC, two timestamps are concurrent only when they are identical
— meaning they were produced by different nodes without communication
at precisely the same (physical, logical) point.
Sourcepub fn to_bytes(self) -> [u8; 12]
pub fn to_bytes(self) -> [u8; 12]
Serialise to a 12-byte big-endian representation suitable for embedding in RPC headers or log entries.
The byte layout preserves the total order: a lexicographic comparison
of the byte arrays gives the same result as Ord.
Sourcepub fn from_bytes(bytes: [u8; 12]) -> Self
pub fn from_bytes(bytes: [u8; 12]) -> Self
Deserialise from bytes produced by to_bytes.
Trait Implementations§
Source§impl Clone for HlcTimestamp
impl Clone for HlcTimestamp
Source§fn clone(&self) -> HlcTimestamp
fn clone(&self) -> HlcTimestamp
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for HlcTimestamp
impl Debug for HlcTimestamp
Source§impl Hash for HlcTimestamp
impl Hash for HlcTimestamp
Source§impl Ord for HlcTimestamp
impl Ord for HlcTimestamp
Source§impl PartialEq for HlcTimestamp
impl PartialEq for HlcTimestamp
Source§impl PartialOrd for HlcTimestamp
impl PartialOrd for HlcTimestamp
impl Copy for HlcTimestamp
impl Eq for HlcTimestamp
impl StructuralPartialEq for HlcTimestamp
Auto Trait Implementations§
impl Freeze for HlcTimestamp
impl RefUnwindSafe for HlcTimestamp
impl Send for HlcTimestamp
impl Sync for HlcTimestamp
impl Unpin for HlcTimestamp
impl UnsafeUnpin for HlcTimestamp
impl UnwindSafe for HlcTimestamp
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