pub struct MVRegister<T: Clone + Ord> { /* private fields */ }Expand description
A multi-value register (MV-Register).
Unlike LWW-Register, this preserves all concurrently written values. When concurrent writes occur, all values are kept until a subsequent write supersedes them. This is useful when you want to detect conflicts rather than silently resolving them.
§Example
use crdt_kit::prelude::*;
let mut r1 = MVRegister::new(1);
r1.set("alice");
let mut r2 = MVRegister::new(2);
r2.set("bob");
r1.merge(&r2);
// Both values are preserved as concurrent writes
let values = r1.values();
assert!(values.contains(&&"alice"));
assert!(values.contains(&&"bob"));Implementations§
Source§impl<T: Clone + Ord> MVRegister<T>
impl<T: Clone + Ord> MVRegister<T>
Trait Implementations§
Source§impl<T: Clone + Clone + Ord> Clone for MVRegister<T>
impl<T: Clone + Clone + Ord> 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<T: Clone + Ord> DeltaCrdt for MVRegister<T>
impl<T: Clone + Ord> DeltaCrdt for MVRegister<T>
Source§type Delta = MVRegisterDelta<T>
type Delta = MVRegisterDelta<T>
The type of delta produced by this CRDT.
Source§fn delta(&self, other: &Self) -> MVRegisterDelta<T>
fn delta(&self, other: &Self) -> MVRegisterDelta<T>
Source§fn apply_delta(&mut self, delta: &MVRegisterDelta<T>)
fn apply_delta(&mut self, delta: &MVRegisterDelta<T>)
Apply a delta to this replica’s state. Read more
impl<T: Eq + Clone + Ord> Eq for MVRegister<T>
impl<T: Clone + Ord> 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>where
T: Unpin,
impl<T> UnsafeUnpin for MVRegister<T>
impl<T> UnwindSafe for MVRegister<T>where
T: UnwindSafe,
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