Skip to main content

Crate diamond_types_extended

Crate diamond_types_extended 

Source
Expand description

§Diamond Types Extended - Unified CRDT Library

Diamond Types Extended provides high-performance CRDTs (Conflict-free Replicated Data Types) for collaborative applications. It’s a fork of diamond-types with an ergonomic, unified API.

§Quick Start

use diamond_types_extended::{Document, Uuid, Value};

// Create a document
let mut doc = Document::new();
let alice = doc.create_agent(Uuid::now_v7());

// All mutations happen in transactions
doc.transact(alice, |tx| {
    tx.root().set("title", "My Document");
    tx.root().set("count", 42);
    tx.root().create_text("content");
});

// Access the text CRDT
doc.transact(alice, |tx| {
    if let Some(mut text) = tx.get_text_mut(&["content"]) {
        text.insert(0, "Hello, world!");
    }
});

// Read values directly
assert_eq!(doc.root().get("title").unwrap().as_str(), Some("My Document"));
assert_eq!(doc.root().get_text("content").unwrap().content(), "Hello, world!");

§CRDT Types

  • Map: Key-value container with LWW (Last-Writer-Wins) registers per key
  • Text: Sequence CRDT for collaborative text editing
  • Set: OR-Set (Observed-Remove) with add-wins semantics
  • Register: Single-value LWW container

All types can be nested within Maps.

§Replication

// Peer A creates some changes
let ops = doc_a.ops_since(&Frontier::root()).into_owned();

// Peer B merges them
doc_b.merge_ops(ops)?;

§Attribution

Diamond Types Extended is built on diamond-types by Joseph Gentle. See ATTRIBUTION.md for details.

Structs§

Conflicted
Wrapper for values that may have concurrent conflicts.
CrdtId
Opaque handle to a nested CRDT within a Document.
Document
A unified CRDT document container.
DocumentWriter
Closure-free mutation handle for FFI/WASM consumers.
Frontier
A LocalFrontier is a set of local Time values which point at the set of changes with no children at this point in time. When there’s a single writer this will always just be the last local version we’ve seen.
MapMut
Mutable reference to a Map CRDT.
MapRef
Read-only reference to a Map CRDT.
NotNan
A wrapper around floats providing an implementation of Eq, Ord and Hash.
RegisterRef
Read-only reference to a Register CRDT.
RemoteVersion
Remote IDs are IDs you can pass to a remote peer. With UUID agent IDs, these are Copy and have no lifetime.
SerializedOps
SerializedOpsOwned
SetMut
Mutable reference to a Set CRDT.
SetRef
Read-only reference to a Set CRDT.
TextMut
Mutable reference to a Text CRDT.
TextRef
Read-only reference to a Text CRDT.
Transaction
A transaction for batched mutations.
Uuid
A Universally Unique Identifier (UUID).

Enums§

MaterializedValue
Fully resolved document tree value.
ParseError
PrimitiveValue
Primitive value type for write operations.
Value
Unified value type for reading from CRDTs.

Type Aliases§

AgentId
LV
An LV (LocalVersion) is used all over the place internally to identify a single operation.
RemoteFrontier