1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
//! # crdt-kit
//!
//! CRDTs optimized for edge computing and local-first applications.
//!
//! A CRDT (Conflict-free Replicated Data Type) is a data structure that can be
//! replicated across multiple devices and updated independently. When replicas
//! are merged, they are guaranteed to converge to the same state without
//! requiring coordination or consensus.
//!
//! ## `no_std` Support
//!
//! This crate supports `no_std` environments with the `alloc` crate.
//! Disable the default `std` feature in your `Cargo.toml`:
//!
//! ```toml
//! [dependencies]
//! crdt-kit = { version = "0.5.0", default-features = false }
//! ```
//!
//! ## Quick Start
//!
//! ```
//! use crdt_kit::prelude::*;
//!
//! // Grow-only counter
//! let mut c1 = GCounter::new(1);
//! c1.increment();
//!
//! let mut c2 = GCounter::new(2);
//! c2.increment();
//!
//! c1.merge(&c2);
//! assert_eq!(c1.value(), 2);
//! ```
//!
//! ## Available CRDTs
//!
//! ### Counters
//! - [`GCounter`] - Grow-only counter (increment only)
//! - [`PNCounter`] - Positive-negative counter (increment and decrement)
//!
//! ### Registers
//! - [`LWWRegister`] - Last-writer-wins register (HLC-based resolution)
//! - [`MVRegister`] - Multi-value register (preserves concurrent writes)
//!
//! ### Sets
//! - [`GSet`] - Grow-only set (add only)
//! - [`TwoPSet`] - Two-phase set (add and remove, remove is permanent)
//! - [`ORSet`] - Observed-remove set (add and remove freely)
//!
//! ### Maps
//! - [`LWWMap`] - Last-writer-wins map (per-key HLC timestamp resolution)
//! - [`AWMap`] - Add-wins map (OR-Set semantics for keys, concurrent add beats remove)
//!
//! ### Sequences
//! - [`Rga`] - Replicated Growable Array (ordered sequence)
//! - [`TextCrdt`] - Collaborative text (thin wrapper over `Rga<char>`)
//!
//! ## The `Crdt` Trait
//!
//! All types implement the [`Crdt`] trait, which provides the [`Crdt::merge`]
//! method. Merge is guaranteed to be commutative, associative, and idempotent.
extern crate alloc;
/// Replicated Growable Array (RGA) — ordered sequence CRDT.
/// Versioned serialization and envelope format.
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;