pub struct VectorClock {
pub clocks: FxHashMap<String, u64>,
}Expand description
Vector clock for causal ordering in distributed systems.
Maps actor IDs to logical counters.
Fields§
§clocks: FxHashMap<String, u64>Implementations§
Source§impl VectorClock
impl VectorClock
pub fn new() -> Self
Sourcepub fn merge_clock(&mut self, other: &VectorClock)
pub fn merge_clock(&mut self, other: &VectorClock)
Merge another vector clock into this one (point-wise maximum).
Sourcepub fn happened_before(&self, other: &VectorClock) -> bool
pub fn happened_before(&self, other: &VectorClock) -> bool
Returns true if self causally happened before other. A < B iff for all k: A[k] <= B[k] AND exists k: A[k] < B[k].
Sourcepub fn is_concurrent(&self, other: &VectorClock) -> bool
pub fn is_concurrent(&self, other: &VectorClock) -> bool
Returns true if neither clock happened before the other (concurrent).
Sourcepub fn causal_cmp(&self, other: &VectorClock) -> Option<Ordering>
pub fn causal_cmp(&self, other: &VectorClock) -> Option<Ordering>
Compare two clocks for causal ordering.
Returns Less/Greater when one clock causally happened before the
other, Equal when they match, and None when they are concurrent.
Named causal_cmp rather than implementing PartialOrd to keep the
concurrent-as-None semantics explicit at call sites.
Trait Implementations§
Source§impl Clone for VectorClock
impl Clone for VectorClock
Source§fn clone(&self) -> VectorClock
fn clone(&self) -> VectorClock
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl CrdtMerge for VectorClock
impl CrdtMerge for VectorClock
Source§impl Debug for VectorClock
impl Debug for VectorClock
Source§impl Default for VectorClock
impl Default for VectorClock
Source§fn default() -> VectorClock
fn default() -> VectorClock
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for VectorClock
impl<'de> Deserialize<'de> for VectorClock
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for VectorClock
impl PartialEq for VectorClock
Source§fn eq(&self, other: &VectorClock) -> bool
fn eq(&self, other: &VectorClock) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for VectorClock
impl Serialize for VectorClock
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<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<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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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>
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 more