pub struct CrdtMeta {
pub timestamp: HlcTimestamp,
pub node_id: NodeId,
}Expand description
Per-entry CRDT metadata for LWW (Last-Writer-Wins) conflict resolution.
20 bytes on wire: entry_kind (1B) + padding (3B) + HLC timestamp (12B) + NodeId (8B).
Conflict resolution: higher timestamp wins, NodeId tiebreaker. This forms a join-semilattice with a total order, guaranteeing:
- Commutativity: merge(a, b) == merge(b, a)
- Associativity: merge(merge(a, b), c) == merge(a, merge(b, c))
- Idempotency: merge(a, a) == a
Fields§
§timestamp: HlcTimestamp§node_id: NodeIdImplementations§
Source§impl CrdtMeta
impl CrdtMeta
Sourcepub fn new(timestamp: HlcTimestamp, node_id: NodeId) -> Self
pub fn new(timestamp: HlcTimestamp, node_id: NodeId) -> Self
Create new CRDT metadata.
Sourcepub fn to_bytes(&self) -> [u8; 20]
pub fn to_bytes(&self) -> [u8; 20]
Serialize to 20 bytes: HLC (12B big-endian) + NodeId (8B big-endian).
Sourcepub fn from_bytes(b: &[u8; 20]) -> Self
pub fn from_bytes(b: &[u8; 20]) -> Self
Deserialize from 20 bytes.
Trait Implementations§
impl Copy for CrdtMeta
impl Eq for CrdtMeta
impl StructuralPartialEq for CrdtMeta
Auto Trait Implementations§
impl Freeze for CrdtMeta
impl RefUnwindSafe for CrdtMeta
impl Send for CrdtMeta
impl Sync for CrdtMeta
impl Unpin for CrdtMeta
impl UnsafeUnpin for CrdtMeta
impl UnwindSafe for CrdtMeta
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