logicaffeine_data/crdt/merge.rs
1//! The Merge trait for CRDTs
2
3/// A type that can be merged with another instance of itself.
4///
5/// The merge operation must satisfy CRDT properties:
6/// - **Commutative**: `a.merge(b) == b.merge(a)` (result is the same regardless of order)
7/// - **Associative**: `a.merge(b.merge(c)) == a.merge(b).merge(c)`
8/// - **Idempotent**: `a.merge(a) == a` (merging with self has no effect)
9///
10/// These properties ensure that replicas converge to the same state
11/// regardless of message ordering or delivery.
12pub trait Merge {
13 /// Merge another instance into self.
14 ///
15 /// After merging, `self` contains the combined state of both instances.
16 fn merge(&mut self, other: &Self);
17}