Skip to main content

Hlc

Struct Hlc 

Source
pub struct Hlc { /* private fields */ }

Implementations§

Source§

impl Hlc

Source

pub fn try_new( device_id: String, clock: ClockRef, ) -> Result<Self, PathTokenError>

Source

pub fn new(device_id: String, clock: ClockRef) -> Self

Create a new HLC with the given device ID.

Source

pub fn device_id(&self) -> &str

Source

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.

Source

pub fn high_water(&self) -> Timestamp

The clock’s current high-water mark: a Timestamp at the latest millis/counter this clock has reached. Persist this whenever the clock advances (on stamp and on apply-merge) and feed it back to Hlc::seed on the next construction.

Source

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.

Source

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.

Source

pub fn now(&self) -> Timestamp

Generate a new timestamp. Guaranteed to be greater than any previous timestamp returned by this clock.

Source

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.

Auto Trait Implementations§

§

impl !Freeze for Hlc

§

impl !RefUnwindSafe for Hlc

§

impl Send for Hlc

§

impl Sync for Hlc

§

impl Unpin for Hlc

§

impl UnsafeUnpin for Hlc

§

impl !UnwindSafe for Hlc

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,