pub struct HybridClock { /* private fields */ }Expand description
Implementations§
Source§impl HybridClock
impl HybridClock
Sourcepub fn new(node_id: u16) -> Self
pub fn new(node_id: u16) -> Self
Create a new clock for the given node.
On std targets, uses SystemTime for physical time.
On no_std targets, use with_time_source.
Sourcepub fn with_time_source(node_id: u16, time_fn: fn() -> u64) -> Self
pub fn with_time_source(node_id: u16, time_fn: fn() -> u64) -> Self
Create a clock with a custom physical time source. The function should return milliseconds (monotonic if possible).
Sourcepub fn now(&mut self) -> HybridTimestamp
pub fn now(&mut self) -> HybridTimestamp
Generate a timestamp for a local event.
Guarantees monotonically increasing timestamps even if the physical clock goes backward.
Sourcepub fn receive(&mut self, remote: &HybridTimestamp) -> HybridTimestamp
pub fn receive(&mut self, remote: &HybridTimestamp) -> HybridTimestamp
Update the clock upon receiving a remote timestamp.
Returns a new timestamp that is strictly greater than both the local clock and the received timestamp.
Sourcepub fn last_timestamp(&self) -> HybridTimestamp
pub fn last_timestamp(&self) -> HybridTimestamp
Get the last generated timestamp.
Auto Trait Implementations§
impl Freeze for HybridClock
impl RefUnwindSafe for HybridClock
impl Send for HybridClock
impl Sync for HybridClock
impl Unpin for HybridClock
impl UnwindSafe for HybridClock
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