pub struct VClock { /* private fields */ }Expand description
A vector clock for tracking causal relationships between events.
Each replica has a logical clock counter. The vector clock captures which events have been “seen” by tracking the maximum counter for each replica.
Implementations§
Source§impl VClock
impl VClock
Sourcepub fn increment(&mut self, replica: ReplicaId) -> u64
pub fn increment(&mut self, replica: ReplicaId) -> u64
Increment the clock for a replica and return the new counter value.
Sourcepub fn get(&self, replica: ReplicaId) -> u64
pub fn get(&self, replica: ReplicaId) -> u64
Get the current counter for a replica (0 if not seen).
Sourcepub fn dominates(&self, other: &Self) -> bool
pub fn dominates(&self, other: &Self) -> bool
Check if self dominates other (self >= other for all replicas).
Returns true if for every replica in other, self has an equal or greater counter.
Sourcepub fn concurrent(&self, other: &Self) -> bool
pub fn concurrent(&self, other: &Self) -> bool
Check if self and other are concurrent (neither dominates the other).
Sourcepub fn merge_vclock(&mut self, other: &Self)
pub fn merge_vclock(&mut self, other: &Self)
Merge another vector clock into this one (pointwise max).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for VClock
impl<'de> Deserialize<'de> for VClock
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
impl Eq for VClock
impl StructuralPartialEq for VClock
Auto Trait Implementations§
impl Freeze for VClock
impl RefUnwindSafe for VClock
impl Send for VClock
impl Sync for VClock
impl Unpin for VClock
impl UnsafeUnpin for VClock
impl UnwindSafe for VClock
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