pub struct LWWRegister<T> { /* private fields */ }Expand description
A register that resolves conflicts using “last write wins” semantics.
Each write records a timestamp, and on merge the value with the higher timestamp is kept.
§Time Injection
Timestamps must be provided by the caller. This makes the type pure and WASM-compatible. Use a logical clock or system time at the call site.
Implementations§
Source§impl<T> LWWRegister<T>
impl<T> LWWRegister<T>
Sourcepub fn new(value: T, timestamp: u64) -> Self
pub fn new(value: T, timestamp: u64) -> Self
Create a new register with the given initial value and timestamp.
The timestamp should be provided by the caller (e.g., from system time or a logical clock). This enables WASM compatibility.
Trait Implementations§
Source§impl<T: Clone> Clone for LWWRegister<T>
impl<T: 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 moreSource§impl<T: Debug> Debug for LWWRegister<T>
impl<T: Debug> Debug for LWWRegister<T>
Source§impl<T: Default> Default for LWWRegister<T>
impl<T: Default> Default for LWWRegister<T>
Source§impl<'de, T> Deserialize<'de> for LWWRegister<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for LWWRegister<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: Clone> Merge for LWWRegister<T>
impl<T: Clone> Merge for LWWRegister<T>
Source§impl<T: PartialEq> PartialEq for LWWRegister<T>
impl<T: PartialEq> PartialEq for LWWRegister<T>
Source§impl<T> Serialize for LWWRegister<T>where
T: Serialize,
impl<T> Serialize for LWWRegister<T>where
T: Serialize,
impl<T> 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> UnsafeUnpin for LWWRegister<T>where
T: UnsafeUnpin,
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