pub trait DocumentType:
Clone
+ Send
+ Sync
+ 'static {
const TYPE_ID: u8;
const TYPE_NAME: &'static str;
// Required methods
fn identity(&self) -> (u32, u64);
fn encode(&self) -> Vec<u8> ⓘ;
fn decode(data: &[u8]) -> Option<Self>
where Self: Sized;
fn merge(&mut self, other: &Self) -> bool;
// Provided methods
fn to_delta_op(&self) -> Option<AppOperation> { ... }
fn apply_delta_op(&mut self, _op: &AppOperation) -> bool { ... }
}Expand description
A registered document type that can be synced through the mesh.
Implementations must be deterministic - the same logical state must encode consistently for merge operations to work correctly. Document identity (source_node, timestamp) is used for deduplication instead of content hash, since CRDT merge may change byte ordering.
Required Associated Constants§
Required Methods§
Sourcefn identity(&self) -> (u32, u64)
fn identity(&self) -> (u32, u64)
Document identity for deduplication.
Returns (source_node, timestamp) tuple that uniquely identifies this document instance.
Provided Methods§
Sourcefn to_delta_op(&self) -> Option<AppOperation>
fn to_delta_op(&self) -> Option<AppOperation>
Convert to a delta operation for efficient sync.
Returns None if this type doesn’t support delta sync (will use full-state sync instead).
Sourcefn apply_delta_op(&mut self, _op: &AppOperation) -> bool
fn apply_delta_op(&mut self, _op: &AppOperation) -> bool
Apply a delta operation to this document.
Returns true if state changed.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.