Skip to main content

vectis_crdt/
lib.rs

1//! # vectis-crdt
2//!
3//! CRDT engine for collaborative whiteboards.
4//!
5//! **vectis** (lat.) = arrow, vector.
6//!
7//! ## Architecture
8//!
9//! See [`ARCHITECTURE.md`] at the crate root for a comprehensive technical
10//! description of every design decision, algorithm, and trade-off.
11//!
12//! ## Quick overview
13//!
14//! The whiteboard state is two independent CRDTs:
15//!
16//! - **[`rga::RgaArray`]** — YATA-style Replicated Growable Array for z-order.
17//!   Each item is a stroke (not a point), so `n` is in the hundreds, not millions.
18//! - **[`stroke::LwwRegister`]** — Last-Write-Wins register per stroke property
19//!   (color, width, opacity, transform). Independent registers enable granular
20//!   concurrent merges without conflict.
21//!
22//! The root entry point is [`document::Document`]. The Wasm-facing API lives in
23//! [`wasm_bridge::WasmDocument`] (feature `wasm`).
24//!
25//! ## Feature flags
26//!
27//! | Feature | Default | Description |
28//! |---------|---------|-------------|
29//! | `wasm` | yes | Enables wasm-bindgen and the JS API |
30//! | `compress` | no | Enables LZ4 compression for updates > 200 B |
31//!
32//! ## Module map
33//!
34//! | Module | Role |
35//! |--------|------|
36//! | [`types`] | `ActorId`, `LamportTs`, `OpId`, `VectorClock` |
37//! | [`rga`] | YATA-style RGA, `RgaArray`, `RgaItem`, `ItemState` |
38//! | [`stroke`] | `StrokePoint`, `StrokeData`, `Aabb`, `LwwRegister`, `StrokeProperties` |
39//! | [`document`] | `Document` root, all CRDT operations, `LwwMap` |
40//! | [`gc`] | Incremental tombstone GC with MVV gating and origin re-parenting |
41//! | [`encoding`] | Binary wire format: LEB128 varints + LE floats |
42//! | [`causal_buffer`] | Buffers out-of-order remote ops until causally deliverable |
43//! | [`awareness`] | Ephemeral cursor positions (TTL-based, not CRDT) |
44//! | [`compression`] | LZ4 feature-gated threshold compression |
45//! | [`error`] | `VectisError`, `VectisResult` |
46//! | [`wasm_bridge`] | `WasmDocument`: zero-copy JS API (feature `wasm`) |
47
48pub mod types;
49pub mod rga;
50pub mod stroke;
51pub mod document;
52pub mod gc;
53pub mod encoding;
54pub mod error;
55pub mod causal_buffer;
56pub mod awareness;
57pub mod compression;
58
59#[cfg(feature = "wasm")]
60pub mod wasm_bridge;
61
62#[cfg(feature = "python")]
63pub mod python;