Skip to main content

braid_core/core/merge/
mod.rs

1//! Merge algorithms and CRDT implementations for conflict resolution.
2//!
3//! This module provides merge strategies for resolving concurrent edits to the same resource
4//! when multiple clients make simultaneous mutations. The module includes built-in support
5//! for CRDT-based merge algorithms.
6//!
7//! # Merge-Types in Braid-HTTP
8//!
9//! Per Section 2.2 of [draft-toomim-httpbis-braid-http-04], resources can declare a merge type
10//! to specify how concurrent edits should be reconciled:
11//!
12//! | Merge Type | Description |
13//! |------------|-------------|
14//! //! | `"diamond"` | Diamond-types CRDT for text documents |
15//! | `"antimatter"` | Antimatter CRDT with pruning |
16//! | Custom | Application-defined merge algorithms |
17//!
18//! # Key Types
19//!
20//! | Type | Description |
21//! |------|-------------|
22//! | [`MergeType`] | Trait for pluggable merge algorithms |
23//! //! | [`AntimatterMergeType`] | Antimatter CRDT with pruning |
24//! | [`DiamondCRDT`] | High-performance text CRDT |
25//! | [`MergeTypeRegistry`] | Factory for creating merge type instances |
26//!
27//! [draft-toomim-httpbis-braid-http-04]: https://datatracker.ietf.org/doc/html/draft-toomim-httpbis-braid-http
28
29pub mod antimatter_merge;
30pub mod merge_type;
31
32#[cfg(not(target_arch = "wasm32"))]
33pub mod diamond;
34
35// Re-exports
36pub use antimatter_merge::AntimatterMergeType;
37pub use merge_type::{MergePatch, MergeResult, MergeType, MergeTypeRegistry};
38
39#[cfg(not(target_arch = "wasm32"))]
40pub use diamond::{DiamondCRDT, DiamondMergeType};