braid_rs
A unified Rust implementation of the Braid Protocol for building decentralized, synchronized web applications.
Features
| Feature | Description |
|---|---|
| Core Braid-HTTP | Full protocol implementation with SSE subscriptions |
| Antimatter CRDT | JS-compatible CRDT with history compression |
| MergeType System | Pluggable merge algorithms (Sync9, Antimatter, Diamond) |
| Braid-Blob | Content-addressable storage with SHA-256 hashing |
| BraidFS | Filesystem sync daemon with .braidignore support |
Quick Start
[]
= "0.1.0"
Braid-HTTP Client
use BraidClient;
async
Antimatter CRDT
use ;
use Patch;
use json;
// Create CRDT with send callback
let mut crdt = new;
// Apply local edit
let version = crdt.update;
// Get current state
println!;
println!;
// Prune history when acknowledged
crdt.prune;
MergeType System
use ;
use json;
// Create registry with built-in types
let mut registry = new;
// Get a merge type by name
let mut merge = registry.create.unwrap;
// Initialize with content
merge.initialize;
// Apply local edit
let patch = new;
let result = merge.local_edit;
println!;
println!;
Axum Server Integration
use ;
use ;
async
let app = new
.route
.layer;
Architecture
braid_rs/
├── src/
│ ├── core/ # Braid-HTTP protocol
│ │ ├── client/ # HTTP client with subscriptions
│ │ ├── server/ # Axum middleware & handlers
│ │ ├── merge/ # MergeType trait & implementations
│ │ └── protocol/ # Protocol constants & types
│ │
│ ├── antimatter/ # Antimatter CRDT (JS-compatible)
│ │ ├── antimatter.rs # Main coordination layer
│ │ ├── sequence_crdt.rs # Text/array CRDT
│ │ ├── json_crdt.rs # Recursive JSON CRDT
│ │ └── messages.rs # Protocol messages
│ │
│ ├── blob/ # Content-addressable storage
│ │ ├── store.rs # SQLite metadata + FS storage
│ │ └── http.rs # Axum HTTP endpoints
│ │
│ └── fs/ # Filesystem sync daemon
│ ├── mod.rs # Daemon & file watching
│ └── config.rs # .braidignore, debouncing
Binaries
braidfs
Sync local files with a Braid server:
# Start the daemon
# Add a sync mapping
braid-blob
Run a standalone blob server:
Configuration
.braidignore
Place a .braidignore file in synced directories:
# Ignore git files
.git
.git/**
# Ignore dependencies
node_modules/**
# Ignore temp files
*.swp
*.swo
*~
BraidFS Config
Location: ~/.braidfs/config
Protocol Compliance
This implementation follows draft-toomim-httpbis-braid-http-04:
| Header | Support |
|---|---|
Subscribe: true |
✅ |
Version |
✅ |
Parents |
✅ |
Merge-Type |
✅ |
Patches |
✅ |
Content-Range |
✅ |
License
Dual-licensed under Apache 2.0 or MIT at your option.