pub struct MVRegister<T: Ord + Clone> { /* private fields */ }Expand description
A Multi-Value Register CRDT
Maintains a set of values, each with a unique dot. This allows concurrent writes to coexist until explicitly resolved.
Implementations§
Source§impl<T: Ord + Clone> MVRegister<T>
impl<T: Ord + Clone> MVRegister<T>
Sourcepub fn write(&mut self, replica_id: &str, value: T) -> Dot
pub fn write(&mut self, replica_id: &str, value: T) -> Dot
Write a new value, generating a unique dot
Sourcepub fn write_with_dot(&mut self, dot: Dot, value: T)
pub fn write_with_dot(&mut self, dot: Dot, value: T)
Write a value with a specific dot (for merging)
Sourcepub fn read_with_dots(&self) -> Vec<(&Dot, &T)>
pub fn read_with_dots(&self) -> Vec<(&Dot, &T)>
Get all current values with their dots
Sourcepub fn resolve(&mut self, replica_id: &str, value: T) -> Dot
pub fn resolve(&mut self, replica_id: &str, value: T) -> Dot
Resolve concurrent values by choosing one (for write-after-read consistency)
Sourcepub fn remove_dot(&mut self, dot: &Dot)
pub fn remove_dot(&mut self, dot: &Dot)
Remove a specific dot (value)
Trait Implementations§
Source§impl<T: Clone + Ord + Clone> Clone for MVRegister<T>
impl<T: Clone + Ord + Clone> Clone for MVRegister<T>
Source§fn clone(&self) -> MVRegister<T>
fn clone(&self) -> MVRegister<T>
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<'de, T: Ord + Clone + Deserialize<'de>> Deserialize<'de> for MVRegister<T>
impl<'de, T: Ord + Clone + Deserialize<'de>> Deserialize<'de> for MVRegister<T>
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<T: Ord + Clone> Lattice for MVRegister<T>
impl<T: Ord + Clone> Lattice for MVRegister<T>
Source§fn join(&self, other: &Self) -> Self
fn join(&self, other: &Self) -> Self
Join operation: union of all values from both registers This represents the concurrent state after a merge
Source§fn partial_cmp_lattice(&self, other: &Self) -> Option<Ordering>
fn partial_cmp_lattice(&self, other: &Self) -> Option<Ordering>
Partial order derived from join: a ≤ b iff a ⊔ b = b
Source§fn join_assign(&mut self, other: &Self)
fn join_assign(&mut self, other: &Self)
Join-assign: self = self ⊔ other
impl<T: Eq + Ord + Clone> Eq for MVRegister<T>
impl<T: Ord + Clone> StructuralPartialEq for MVRegister<T>
Auto Trait Implementations§
impl<T> Freeze for MVRegister<T>
impl<T> RefUnwindSafe for MVRegister<T>where
T: RefUnwindSafe,
impl<T> Send for MVRegister<T>where
T: Send,
impl<T> Sync for MVRegister<T>where
T: Sync,
impl<T> Unpin for MVRegister<T>
impl<T> UnwindSafe for MVRegister<T>where
T: RefUnwindSafe,
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