pub struct HlcClock<C: PhysicalClock = SystemClock> { /* private fields */ }Expand description
Hybrid Logical Clock state machine.
Two core operations:
now() always returns a strictly increasing timestamp.
update() advances the internal clock state without generating a new timestamp.
Timestamps are only generated by local events; received timestamps only advance
the clock.
Implementations§
Source§impl<C: PhysicalClock> HlcClock<C>
impl<C: PhysicalClock> HlcClock<C>
pub fn with_clock(clock: C) -> Self
pub fn set_max_drift_ns(&mut self, max_drift_ns: i64)
Sourcepub fn set_last(&mut self, ts: HlcTimestamp)
pub fn set_last(&mut self, ts: HlcTimestamp)
Call on startup to restore monotonicity after a restart.
Sourcepub fn now(&mut self) -> Result<HlcTimestamp, ClockError>
pub fn now(&mut self) -> Result<HlcTimestamp, ClockError>
Generate a monotonically increasing timestamp for a local event.
Sourcepub fn update(&mut self, remote: HlcTimestamp) -> Result<(), ClockError>
pub fn update(&mut self, remote: HlcTimestamp) -> Result<(), ClockError>
Merge a remote timestamp into local state (does not generate a new timestamp).
pub fn last_timestamp(&self) -> HlcTimestamp
pub fn physical_clock(&self) -> &C
Trait Implementations§
Auto Trait Implementations§
impl<C> Freeze for HlcClock<C>where
C: Freeze,
impl<C> RefUnwindSafe for HlcClock<C>where
C: RefUnwindSafe,
impl<C> Send for HlcClock<C>
impl<C> Sync for HlcClock<C>where
C: Sync,
impl<C> Unpin for HlcClock<C>where
C: Unpin,
impl<C> UnsafeUnpin for HlcClock<C>where
C: UnsafeUnpin,
impl<C> UnwindSafe for HlcClock<C>where
C: UnwindSafe,
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