pub struct MVRegister<T> { /* private fields */ }Expand description
A register that keeps all concurrent values.
Unlike LWW-Register which silently picks a winner, MVRegister preserves all concurrent writes so conflicts can be detected and resolved.
Implementations§
Source§impl<T> MVRegister<T>
impl<T> MVRegister<T>
Sourcepub fn new(replica_id: ReplicaId) -> Self
pub fn new(replica_id: ReplicaId) -> Self
Create a new empty register with a specific replica ID.
Sourcepub fn new_random() -> Self
pub fn new_random() -> Self
Create a new register with a random replica ID.
Sourcepub fn replica_id(&self) -> ReplicaId
pub fn replica_id(&self) -> ReplicaId
Get the replica ID for this register.
Source§impl<T: Clone + PartialEq> MVRegister<T>
impl<T: Clone + PartialEq> MVRegister<T>
Sourcepub fn set(&mut self, value: T)
pub fn set(&mut self, value: T)
Set a new value, creating a new version that dominates all current values.
Sourcepub fn values(&self) -> Vec<&T>
pub fn values(&self) -> Vec<&T>
Get all current values.
If there’s only one value, there’s no conflict. Multiple values indicate concurrent writes that need resolution.
Sourcepub fn resolve(&mut self, value: T)
pub fn resolve(&mut self, value: T)
Resolve a conflict by setting a new value.
This is the same as set, but semantically indicates conflict resolution.
Sourcepub fn has_conflict(&self) -> bool
pub fn has_conflict(&self) -> bool
Check if there’s a conflict (more than one value).
Trait Implementations§
Source§impl<T: Clone> Clone for MVRegister<T>
impl<T: 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<T: Debug> Debug for MVRegister<T>
impl<T: Debug> Debug for MVRegister<T>
Source§impl<T: Clone + PartialEq + Serialize + DeserializeOwned + Send + 'static> DeltaCrdt for MVRegister<T>
impl<T: Clone + PartialEq + Serialize + DeserializeOwned + Send + 'static> DeltaCrdt for MVRegister<T>
Source§impl<'de, T> Deserialize<'de> for MVRegister<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for MVRegister<T>where
T: Deserialize<'de>,
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: PartialEq> PartialEq for MVRegister<T>
impl<T: PartialEq> PartialEq for MVRegister<T>
Source§impl<T> Serialize for MVRegister<T>where
T: Serialize,
impl<T> Serialize for MVRegister<T>where
T: Serialize,
impl<T> 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