Crate armature_collab

Crate armature_collab 

Source
Expand description

Real-time Collaboration Module for Armature Framework

Provides CRDTs (Conflict-free Replicated Data Types) and collaboration primitives for building real-time collaborative applications.

§Overview

┌─────────────────────────────────────────────────────────────────┐
│                    Collaboration Architecture                    │
│                                                                  │
│  ┌──────────┐    ┌──────────┐    ┌──────────┐    ┌──────────┐  │
│  │ Client A │───▶│  CRDT    │───▶│  Sync    │◀───│ Client B │  │
│  └──────────┘    │  State   │    │  Engine  │    └──────────┘  │
│                  └──────────┘    └──────────┘                   │
│                       │               │                         │
│                       ▼               ▼                         │
│                  ┌──────────┐    ┌──────────┐                   │
│                  │ Document │    │ Presence │                   │
│                  │  State   │    │  State   │                   │
│                  └──────────┘    └──────────┘                   │
└─────────────────────────────────────────────────────────────────┘

§Quick Start

use armature_collab::{Document, TextCrdt, CollabSession};

// Create a collaborative document
let doc = Document::new("doc-123");

// Add a text field with CRDT
let text = doc.add_text("content");

// Make edits (automatically synced)
text.insert(0, "Hello, ");
text.insert(7, "World!");

// Subscribe to changes
doc.on_change(|change| {
    println!("Document updated: {:?}", change);
});

§CRDT Types

TypeUse CaseMerge Strategy
LwwRegisterSingle valuesLast-Writer-Wins
GCounterIncrement-only countersMax per replica
PnCounterInc/dec countersG-Counter pair
GSetAppend-only setsUnion
OrSetAdd/remove setsObserved-Remove
LwwMapKey-value storesLWW per key
RgaTextCollaborative textRGA algorithm

§Features

  • text - Text CRDT with RGA algorithm (default)
  • websocket - WebSocket sync integration
  • full - All features

Re-exports§

pub use crdt::*;
pub use document::*;
pub use error::*;
pub use presence::*;
pub use session::*;
pub use sync::*;
pub use text::*;

Modules§

crdt
Core CRDT (Conflict-free Replicated Data Type) implementations
document
Collaborative document abstraction
error
Error types for collaboration module
presence
Presence and awareness for collaborative sessions
session
Collaboration session management
sync
Synchronization protocol for collaborative editing
text
Text CRDT for collaborative text editing

Structs§

LogicalClock
Logical timestamp for ordering operations
Operation
An operation that can be applied to a CRDT
ReplicaId
Unique identifier for a replica (client/node)
VectorClock
Vector clock for tracking causality