Skip to main content

mdcs_sdk/
lib.rs

1//! MDCS SDK - High-level SDK for building collaborative applications
2//!
3//! This SDK provides a simple, ergonomic API for building real-time
4//! collaborative applications using the MDCS (Merkle-Delta CRDT Store).
5//!
6//! # Quick Start
7//!
8//! ```rust
9//! use mdcs_sdk::{Client, ClientConfig};
10//!
11//! // Create a client with a unique replica ID
12//! let config = ClientConfig {
13//!     user_name: "Alice".to_string(),
14//!     ..Default::default()
15//! };
16//! let client = Client::new_with_memory_transport(config);
17//!
18//! // Create a collaborative session
19//! let session = client.create_session("my-session");
20//!
21//! // Open a text document
22//! let doc = session.open_text_doc("meeting-notes");
23//!
24//! // Edit the document
25//! doc.write().insert(0, "# Meeting Notes\n");
26//!
27//! // Read the content
28//! let content = doc.read().get_text();
29//! ```
30//!
31//! # Architecture
32//!
33//! The SDK is organized into several modules:
34//!
35//! - [`client`] - Main entry point for creating and managing collaborative sessions
36//! - [`document`] - Document types (text, rich text, JSON)
37//! - [`presence`] - Real-time cursor and user presence
38//! - [`sync`] - Network synchronization and peer management
39//! - [`network`] - Network transport abstractions
40//! - [`session`] - Session management for collaborative editing
41//! - [`error`] - Error types
42
43pub mod client;
44pub mod document;
45pub mod error;
46pub mod network;
47pub mod presence;
48pub mod session;
49pub mod sync;
50
51// Re-exports for convenience
52pub use client::{Client, ClientConfig, ClientConfigBuilder};
53pub use document::{CollaborativeDoc, DocEvent, JsonDoc, RichTextDoc, TextDoc};
54pub use error::{Result, SdkError};
55pub use network::{MemoryTransport, Message, NetworkTransport, Peer, PeerId, PeerState};
56pub use presence::{Awareness, AwarenessEvent, CursorInfo, UserPresenceInfo};
57pub use session::{Session, SessionEvent};
58pub use sync::{SyncConfig, SyncConfigBuilder, SyncEvent, SyncManager};
59
60// Re-export commonly used types from mdcs-db
61pub use mdcs_db::{
62    json_crdt::{JsonPath, JsonValue},
63    presence::{Cursor, UserId, UserInfo, UserStatus},
64    rich_text::MarkType,
65};
66
67/// Prelude module for convenient imports.
68pub mod prelude {
69    pub use crate::client::{Client, ClientConfig};
70    pub use crate::document::{CollaborativeDoc, JsonDoc, RichTextDoc, TextDoc};
71    pub use crate::error::SdkError;
72    pub use crate::network::{NetworkTransport, Peer, PeerId};
73    pub use crate::presence::{Awareness, CursorInfo};
74    pub use crate::session::Session;
75    pub use crate::sync::{SyncConfig, SyncManager};
76}