pub struct Hlc { /* private fields */ }Expand description
Hybrid Logical Clock.
Thread-safe via interior Mutex. Create one per application lifetime,
pass by reference to write methods.
Implementations§
Source§impl Hlc
impl Hlc
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 update(&self, remote: &Timestamp) -> Timestamp
pub fn update(&self, remote: &Timestamp) -> Timestamp
Merge with a remote timestamp. Advances the local clock to maintain the “happened after” relationship. Returns the new local timestamp.
Implements a clock skew guard: if the remote’s wall time is more than 24 hours ahead of local wall time, we accept the remote but don’t advance our physical clock past local wall time.
Auto Trait Implementations§
impl !Freeze for Hlc
impl !RefUnwindSafe for Hlc
impl Send for Hlc
impl Sync for Hlc
impl Unpin for Hlc
impl !UnwindSafe for Hlc
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.