pub struct VersionVector {
entries: BTreeMap<String, u64>,
}Expand description
A version vector tracking the frontier of seen updates per replica.
Version vectors provide a compact summary of causal history when updates from each replica are contiguous (no gaps).
Fields§
§entries: BTreeMap<String, u64>Map from replica ID to highest seen sequence number.
Implementations§
Source§impl VersionVector
impl VersionVector
Sourcepub fn from_entries(entries: impl IntoIterator<Item = (String, u64)>) -> Self
pub fn from_entries(entries: impl IntoIterator<Item = (String, u64)>) -> Self
Create a version vector from entries.
Sourcepub fn set(&mut self, replica_id: impl Into<String>, sequence: u64)
pub fn set(&mut self, replica_id: impl Into<String>, sequence: u64)
Set the sequence number for a replica.
Sourcepub fn increment(&mut self, replica_id: impl Into<String>) -> u64
pub fn increment(&mut self, replica_id: impl Into<String>) -> u64
Increment the sequence number for a replica, returning the new value.
Sourcepub fn dominates(&self, other: &VersionVector) -> bool
pub fn dominates(&self, other: &VersionVector) -> bool
Check if this vector dominates another (is causally after or concurrent). Returns true if for all replicas, self[r] >= other[r].
Sourcepub fn strictly_dominates(&self, other: &VersionVector) -> bool
pub fn strictly_dominates(&self, other: &VersionVector) -> bool
Check if this vector is strictly greater than another. Returns true if dominates(other) AND self != other.
Sourcepub fn is_concurrent_with(&self, other: &VersionVector) -> bool
pub fn is_concurrent_with(&self, other: &VersionVector) -> bool
Check if two vectors are concurrent (neither dominates the other).
Sourcepub fn merge(&mut self, other: &VersionVector)
pub fn merge(&mut self, other: &VersionVector)
Merge with another version vector (component-wise max).
Sourcepub fn merged_with(&self, other: &VersionVector) -> VersionVector
pub fn merged_with(&self, other: &VersionVector) -> VersionVector
Create a merged version vector without modifying self.
Sourcepub fn min_with(&self, other: &VersionVector) -> VersionVector
pub fn min_with(&self, other: &VersionVector) -> VersionVector
Get the minimum across all replicas in both vectors. This represents the “stable” point that all replicas have seen.
Sourcepub fn total_operations(&self) -> u64
pub fn total_operations(&self) -> u64
Get the sum of all sequence numbers (total operations seen).
Sourcepub fn to_entries(&self) -> Vec<VectorEntry>
pub fn to_entries(&self) -> Vec<VectorEntry>
Convert to a list of entries.
Sourcepub fn from_entry_list(entries: Vec<VectorEntry>) -> Self
pub fn from_entry_list(entries: Vec<VectorEntry>) -> Self
Create from a list of entries.
Trait Implementations§
Source§impl Clone for VersionVector
impl Clone for VersionVector
Source§fn clone(&self) -> VersionVector
fn clone(&self) -> VersionVector
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more