armature-collab 0.1.1

Real-time collaboration with CRDTs and Operational Transformation for Armature framework
Documentation

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

Type Use Case Merge Strategy
LwwRegister Single values Last-Writer-Wins
GCounter Increment-only counters Max per replica
PnCounter Inc/dec counters G-Counter pair
GSet Append-only sets Union
OrSet Add/remove sets Observed-Remove
LwwMap Key-value stores LWW per key
RgaText Collaborative text RGA algorithm

Features

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