oxigdal-sync
Multi-device synchronization library for OxiGDAL with CRDTs, vector clocks, and operational transformation.
Features
-
CRDTs (Conflict-free Replicated Data Types)
- LWW-Register (Last-Write-Wins Register)
- G-Counter (Grow-only Counter)
- PN-Counter (Positive-Negative Counter)
- OR-Set (Observed-Remove Set)
-
Vector Clocks for causality tracking in distributed systems
-
Operational Transformation for concurrent text editing
- Text operations (insert, delete, retain)
- Operation composition and transformation
- Conflict resolution
-
Multi-device Coordination
- Device registration and status management
- Sync session tracking
- State synchronization protocols
-
Merkle Trees for efficient change detection and verification
-
Delta Encoding for bandwidth-efficient data transfer
Usage
CRDTs
use ;
// Last-Write-Wins Register
let mut reg = new;
reg.set;
// G-Counter (grow-only)
let mut counter = new;
counter.increment;
// PN-Counter (increment/decrement)
let mut counter = new;
counter.increment;
counter.decrement;
// OR-Set
let mut set = new;
set.insert;
set.insert;
Vector Clocks
use ;
let mut clock1 = new;
let mut clock2 = new;
clock1.tick;
clock2.tick;
match clock1.compare
Multi-device Coordination
use SyncCoordinator;
let coordinator = new;
// Register devices
coordinator.register_device?;
// Start sync session
let session = coordinator.start_sync_session?;
// ... perform synchronization ...
// Complete session
coordinator.complete_sync_session?;
Merkle Trees
use MerkleTree;
let data = vec!;
let tree = from_data?;
// Verify data
assert!;
// Compare trees
let differences = tree1.diff;
Delta Encoding
use DeltaEncoder;
let encoder = default_encoder;
let base = b"hello world";
let target = b"hello world!";
let delta = encoder.encode?;
let result = delta.apply?;
assert_eq!;
License
Apache-2.0