Skip to main content

mdcs_db/
lib.rs

1//! # mdcs-db
2//!
3//! Database layer for the MDCS (Merkle-Delta CRDT Store).
4//!
5//! This crate provides:
6//! - Document-based API with path operations
7//! - Collaborative text (RGAText, RichText)
8//! - JSON/Object CRDT for flexible schemas
9//! - Presence and awareness for real-time collaboration
10//! - Undo/Redo support
11//!
12//! ## Example
13//!
14//! ```rust,ignore
15//! use mdcs_db::{DocumentStore, DocumentId, JsonValue};
16//!
17//! let mut store = DocumentStore::new("replica_1");
18//!
19//! // Create a text document
20//! let doc_id = store.create_text("My Document");
21//! store.text_insert(&doc_id, 0, "Hello World").unwrap();
22//!
23//! // Create a JSON document
24//! let json_id = store.create_json("Config");
25//! store.json_set(&json_id, "name", JsonValue::String("Test".into())).unwrap();
26//!
27//! // Rich text with formatting
28//! let rich_id = store.create_rich_text("Formatted");
29//! store.rich_text_insert(&rich_id, 0, "Bold text").unwrap();
30//! store.rich_text_bold(&rich_id, 0, 4).unwrap();
31//! ```
32
33pub mod document;
34pub mod error;
35pub mod json_crdt;
36pub mod presence;
37pub mod rga_list;
38pub mod rga_text;
39pub mod rich_text;
40pub mod undo;
41
42// RGA List exports
43pub use rga_list::{ListId, ListNode, RGAList, RGAListDelta};
44
45// RGA Text exports
46pub use rga_text::{RGAText, RGATextDelta, TextId};
47
48// Rich Text exports
49pub use rich_text::{Anchor, Mark, MarkId, MarkType, RichText, RichTextDelta};
50
51// JSON CRDT exports
52pub use json_crdt::{
53    ArrayChange, ArrayId, JsonCrdt, JsonCrdtDelta, JsonPath, JsonValue, ObjectChange, ObjectId,
54    PathSegment,
55};
56
57// Document Store exports
58pub use document::{
59    CrdtValue, Document, DocumentDelta, DocumentId, DocumentStore, DocumentType, QueryOptions,
60    SortField, StoreChange,
61};
62
63// Presence exports
64pub use presence::{
65    Cursor, CursorBuilder, CursorColors, PresenceDelta, PresenceTracker, UserId, UserInfo,
66    UserPresence, UserStatus,
67};
68
69// Undo/Redo exports
70pub use undo::{
71    CollaborativeUndoManager, FormatOperation, GroupId, JsonOperation, Operation, OperationId,
72    TextOperation, UndoManager, UndoableOperation,
73};
74
75// Error exports
76pub use error::DbError;