pub struct LwwRegister<T: Clone> { /* private fields */ }Expand description
A Last-Writer-Wins Register
Stores a single value where concurrent writes are resolved by timestamp. Higher timestamp wins. In case of tie, higher node ID wins.
Implementations§
Source§impl<T: Clone> LwwRegister<T>
impl<T: Clone> LwwRegister<T>
Sourcepub fn new(value: T, timestamp: Timestamp, node_id: NodeId) -> Self
pub fn new(value: T, timestamp: Timestamp, node_id: NodeId) -> Self
Create a new register with an initial value
Sourcepub fn set(&mut self, value: T, timestamp: Timestamp, node_id: NodeId) -> bool
pub fn set(&mut self, value: T, timestamp: Timestamp, node_id: NodeId) -> bool
Set a new value if it has a higher timestamp
Returns true if the value was updated
Sourcepub fn merge(&mut self, other: &LwwRegister<T>) -> bool
pub fn merge(&mut self, other: &LwwRegister<T>) -> bool
Merge with another register (LWW semantics)
Returns true if our value was updated
Trait Implementations§
Source§impl<T: Clone + Clone> Clone for LwwRegister<T>
impl<T: Clone + Clone> Clone for LwwRegister<T>
Source§fn clone(&self) -> LwwRegister<T>
fn clone(&self) -> LwwRegister<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 moreimpl<T: Clone> StructuralPartialEq for LwwRegister<T>
Auto Trait Implementations§
impl<T> Freeze for LwwRegister<T>where
T: Freeze,
impl<T> RefUnwindSafe for LwwRegister<T>where
T: RefUnwindSafe,
impl<T> Send for LwwRegister<T>where
T: Send,
impl<T> Sync for LwwRegister<T>where
T: Sync,
impl<T> Unpin for LwwRegister<T>where
T: Unpin,
impl<T> UnwindSafe for LwwRegister<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