Development Documentation (main branch) - For stable release docs, see docs.rs/eidetica

CRDT

Trait CRDT 

Source
pub trait CRDT: Data + Default {
    // Required method
    fn merge(&self, other: &Self) -> Result<Self>
       where Self: Sized;
}
Expand description

A trait for Conflict-free Replicated Data Types (CRDTs).

CRDTs are data structures that can be replicated across multiple nodes and automatically resolve conflicts without requiring coordination between nodes. They guarantee that concurrent updates can be merged deterministically, ensuring eventual consistency.

All CRDT types must also implement the Data trait, ensuring they can be stored and serialized within the Eidetica database.

§Examples

use eidetica::crdt::{CRDT, Data, Doc};
use eidetica::Result;

let mut kv1 = Doc::new();
kv1.set("key", "value1");

let mut kv2 = Doc::new();
kv2.set("key", "value2");

let merged = kv1.merge(&kv2).unwrap();
// Doc uses last-write-wins semantics for scalar values

Required Methods§

Source

fn merge(&self, other: &Self) -> Result<Self>
where Self: Sized,

Merge this CRDT with another instance, returning a new merged instance.

This operation must be:

  • Associative: (a.merge(b)).merge(c) == a.merge(b.merge(c))

Unlike traditional state-based CRDTs (which require a join-semilattice with commutativity and idempotency), Eidetica’s Merkle-CRDT design relaxes these requirements. The Merkle DAG provides deterministic traversal order, eliminating the need for commutativity, and ensures each entry is applied exactly once, eliminating the need for idempotency.

§Arguments
  • other - The other CRDT instance to merge with
§Returns

A new CRDT instance representing the merged state, or an error if the merge fails.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§