Skip to main content

crdt_kit/
crdt.rs

1/// Core trait that all CRDTs must implement.
2///
3/// A CRDT (Conflict-free Replicated Data Type) guarantees that concurrent
4/// updates on different replicas will converge to the same state after merging,
5/// without requiring coordination.
6///
7/// # Properties
8///
9/// All implementations must satisfy:
10/// - **Commutativity:** `a.merge(b) == b.merge(a)`
11/// - **Associativity:** `a.merge(b.merge(c)) == a.merge(b).merge(c)`
12/// - **Idempotency:** `a.merge(a) == a`
13pub trait Crdt {
14    /// Merge another replica's state into this one.
15    ///
16    /// After merging, `self` contains the least upper bound of both states.
17    /// This operation is commutative, associative, and idempotent.
18    fn merge(&mut self, other: &Self);
19}