pub struct Hlc {
pub physical_nanos: i64,
pub logical: u32,
}Expand description
A Hybrid Logical Clock timestamp: a physical instant (nanoseconds) plus a logical counter
that breaks ties and preserves causality when the physical clock stalls, jumps backward, or two
events share a nanosecond. The total order is lexicographic (physical_nanos, logical) — so the
derived Ord is the HLC order. This is the causally-consistent timestamp the SyncClock CRDT
keys on: it stays monotonic and orders happens-before correctly even across machines whose wall
clocks disagree (the bounded-skew / interplanetary case the campaign targets).
Fields§
§physical_nanos: i64§logical: u32Implementations§
Source§impl Hlc
impl Hlc
Sourcepub fn tick(self, now_nanos: i64) -> Hlc
pub fn tick(self, now_nanos: i64) -> Hlc
Stamp a local event (or a send) given the current physical clock now_nanos. Advances
the physical component to max(self, now); the logical counter increments when physical
does not move (a stall or backward jump) and resets to 0 when it does.
Sourcepub fn recv(self, remote: Hlc, now_nanos: i64) -> Hlc
pub fn recv(self, remote: Hlc, now_nanos: i64) -> Hlc
Stamp the receipt of a message carrying timestamp remote, at local physical clock
now_nanos. Merges both clocks plus wall time, keeping the result strictly after both
inputs (the HLC receive rule) so causality (send → receive) is always preserved.