pub struct LwwRegister<T> {
pub value: T,
pub stamp: Stamp,
pub wall_ts: u64,
pub agent_id: String,
pub event_hash: String,
}Expand description
A Last-Writer-Wins register holding a value of type T.
Each write records the value along with metadata used for deterministic merge: an ITC stamp for causal ordering, a wall-clock timestamp, the writing agent’s ID, and the event hash.
Fields§
§value: TThe current value of the register.
stamp: StampITC stamp for causal ordering.
wall_ts: u64Wall-clock timestamp in microseconds since Unix epoch.
agent_id: StringAgent identifier (e.g., “alice”, “bot-1”).
event_hash: StringBLAKE3 hash of the event that wrote this value.
Implementations§
Source§impl<T> LwwRegister<T>
impl<T> LwwRegister<T>
Source§impl<T: Clone> LwwRegister<T>
impl<T: Clone> LwwRegister<T>
Sourcepub fn merge(&mut self, other: &Self)
pub fn merge(&mut self, other: &Self)
Merge another register into this one, keeping the “winning” value.
The 4-step tie-breaking chain:
- ITC causal dominance (non-concurrent: later wins)
- Wall-clock timestamp (concurrent: higher wins)
- Agent ID (lexicographic: greater wins)
- Event hash (lexicographic: greater wins — guaranteed unique)
After merge, self contains the winning value.
Sourcepub fn merge_with_trace(&mut self, other: &Self, field: &str) -> MergeTracewhere
T: Display,
pub fn merge_with_trace(&mut self, other: &Self, field: &str) -> MergeTracewhere
T: Display,
Merge and optionally emit structured decision trace.
If tracing is disabled via environment toggles, returns a no-op trace payload and preserves the normal low-overhead merge path.
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>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<T: Debug> Debug for LwwRegister<T>
impl<T: Debug> Debug 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>,
Source§impl<T: Display> Display for LwwRegister<T>
impl<T: Display> Display for LwwRegister<T>
Source§impl<T: Clone> From<&LwwRegister<T>> for LwwSnapshot<T>
impl<T: Clone> From<&LwwRegister<T>> for LwwSnapshot<T>
Source§fn from(reg: &LwwRegister<T>) -> Self
fn from(reg: &LwwRegister<T>) -> Self
Source§impl<T: Clone> From<&LwwSnapshot<T>> for LwwRegister<T>
impl<T: Clone> From<&LwwSnapshot<T>> for LwwRegister<T>
Source§fn from(snap: &LwwSnapshot<T>) -> Self
fn from(snap: &LwwSnapshot<T>) -> Self
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: Eq> Eq for LwwRegister<T>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.