pub struct Hlc { /* private fields */ }Implementations§
Source§impl Hlc
impl Hlc
pub fn try_new( device_id: String, clock: ClockRef, ) -> Result<Self, PathTokenError>
Sourcepub fn new(device_id: String, clock: ClockRef) -> Self
pub fn new(device_id: String, clock: ClockRef) -> Self
Create a new HLC with the given device ID.
pub fn device_id(&self) -> &str
Sourcepub fn seed(&self, high_water: &Timestamp)
pub fn seed(&self, high_water: &Timestamp)
Seed the clock’s monotonic state from a persisted high-water mark so it cannot mint a stamp behind a value it minted (or saw) before a restart.
Idempotent and monotonic: a seed below the current state is ignored, so
re-seeding can only push the clock forward. The seeded device_id is
irrelevant — only millis/counter gate future stamps.
Sourcepub fn high_water(&self) -> Timestamp
pub fn high_water(&self) -> Timestamp
Sourcepub fn transaction(&self) -> HlcTransaction<'_>
pub fn transaction(&self) -> HlcTransaction<'_>
Stage clock changes while retaining exclusive access to this clock.
Keep the guard through the synchronous database transaction, persist its
high-water mark with the rows, and call HlcTransaction::commit only
after the database commits. Dropping the guard discards staged changes.
Other clock operations wait for the guard; code holding it must use the
guard’s methods instead of locking this clock again.
Sourcepub fn wall_now_ms(&self) -> u64
pub fn wall_now_ms(&self) -> u64
The receiver’s current wall-clock millis, read from the same injected
source the clock stamps from. This is the reference the pull bounds an
incoming _updated_at against (see Timestamp::is_within_future_bound):
it is the receiver’s view of “now”, in the same millis unit as a stamp’s
physical component — never an author-supplied value. Read once per pull and
passed down, not sampled in a loop.
Sourcepub fn now(&self) -> Timestamp
pub fn now(&self) -> Timestamp
Generate a new timestamp. Guaranteed to be greater than any previous timestamp returned by this clock.
Sourcepub fn advance_past(&self, remote: &Timestamp)
pub fn advance_past(&self, remote: &Timestamp)
Record an accepted row or metadata timestamp as the clock floor, so the
next local stamp sorts after it. remote is an authoritative register
value the LWW layer already accepted and wrote to disk — never an
untrusted peer wall clock — so recording it is unconditional: no skew
cap. Capping here would let the next local edit mint a stamp below an
already-stored applied row and lose LWW to it.
Monotonic: a remote ahead of the current state becomes the state floor;
one behind it is ignored. Either way the next Self::now outranks remote.