pub struct LamportClock { /* private fields */ }Expand description
A Lamport logical clock for causal ordering of events.
Lamport clocks provide a partial ordering of events in a distributed system
without requiring synchronized wall clocks. The key property is:
if event A happened-before event B, then clock(A) < clock(B).
§Example
use converge_core::integrity::LamportClock;
let mut clock = LamportClock::new();
assert_eq!(clock.time(), 0);
clock.tick();
assert_eq!(clock.time(), 1);
// When receiving a message with clock=5, update to max+1
clock.update(5);
assert_eq!(clock.time(), 6);Implementations§
Source§impl LamportClock
impl LamportClock
Trait Implementations§
Source§impl Clone for LamportClock
impl Clone for LamportClock
Source§fn clone(&self) -> LamportClock
fn clone(&self) -> LamportClock
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LamportClock
impl Debug for LamportClock
Source§impl Default for LamportClock
impl Default for LamportClock
Source§fn default() -> LamportClock
fn default() -> LamportClock
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for LamportClock
impl<'de> Deserialize<'de> for LamportClock
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<LamportClock, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<LamportClock, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Ord for LamportClock
impl Ord for LamportClock
Source§fn cmp(&self, other: &LamportClock) -> Ordering
fn cmp(&self, other: &LamportClock) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for LamportClock
impl PartialEq for LamportClock
Source§impl PartialOrd for LamportClock
impl PartialOrd for LamportClock
Source§impl Serialize for LamportClock
impl Serialize for LamportClock
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl Copy for LamportClock
impl Eq for LamportClock
impl StructuralPartialEq for LamportClock
Auto Trait Implementations§
impl Freeze for LamportClock
impl RefUnwindSafe for LamportClock
impl Send for LamportClock
impl Sync for LamportClock
impl Unpin for LamportClock
impl UnsafeUnpin for LamportClock
impl UnwindSafe for LamportClock
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.