pub struct VectorClock {
pub entries: HashMap<String, u64>,
}Expand description
A logical clock that tracks causality per node.
Each node maintains a counter that is incremented whenever the node produces a new event. The happened-before relation (→) is defined by Lamport/Mattern vector clock rules.
Fields§
§entries: HashMap<String, u64>Map from node_id to that node’s logical counter.
Implementations§
Source§impl VectorClock
impl VectorClock
Sourcepub fn merge(&self, other: &VectorClock) -> VectorClock
pub fn merge(&self, other: &VectorClock) -> VectorClock
Element-wise maximum of self and other.
The result is the smallest vector clock that dominates both inputs,
i.e. self.merge(other).dominates(self) && self.merge(other).dominates(other).
Sourcepub fn happens_before(&self, other: &VectorClock) -> bool
pub fn happens_before(&self, other: &VectorClock) -> bool
self → other: every component of self is ≤ the corresponding component
of other, and at least one is strictly less.
Sourcepub fn concurrent_with(&self, other: &VectorClock) -> bool
pub fn concurrent_with(&self, other: &VectorClock) -> bool
Two clocks are concurrent when neither happens-before the other.
Sourcepub fn dominates(&self, other: &VectorClock) -> bool
pub fn dominates(&self, other: &VectorClock) -> bool
self dominates other: every component of self is ≥ the corresponding
component of other (i.e. other → self or other == self).
Note: this is not strict; equal clocks both dominate each other.
Trait Implementations§
Source§impl Clone for VectorClock
impl Clone for VectorClock
Source§fn clone(&self) -> VectorClock
fn clone(&self) -> VectorClock
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for VectorClock
impl Debug for VectorClock
Source§impl Default for VectorClock
impl Default for VectorClock
Source§fn default() -> VectorClock
fn default() -> VectorClock
impl Eq for VectorClock
Source§impl PartialEq for VectorClock
impl PartialEq for VectorClock
Source§fn eq(&self, other: &VectorClock) -> bool
fn eq(&self, other: &VectorClock) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for VectorClock
Auto Trait Implementations§
impl Freeze for VectorClock
impl RefUnwindSafe for VectorClock
impl Send for VectorClock
impl Sync for VectorClock
impl Unpin for VectorClock
impl UnsafeUnpin for VectorClock
impl UnwindSafe for VectorClock
Blanket Implementations§
impl<T> Allocation for T
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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
key and return true if they are equal.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§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
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>
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 more