yrs_tree
A tree CRDT for Yrs, a Rust implementation of Yjs, based on the algorithm described in Evan Wallace's article on CRDT Mutable Tree Hierarchies. Changes among clients are guaranteed to converge to a consistent state, and the tree ensures that conflicts and cycles are handled correctly.
Each node in the tree has an ID. The root node is always NodeId::Root
; user-created nodes have IDs of the form NodeId::Id(String)
. Nodes can be accessed by their ID using the [Tree::get_node
] method.
Each node can also store and retrieve arbitrary data associated with that node. See the [Node::set
] and [Node::get
]/[Node::get_as
] methods for more information.
Installation
Documentation
You can find the complete documentation on Docs.rs.
Quick links:
Tree Poisoning
When the underlying Yrs document is updated, the tree automatically updates its state in response. If the library detects that the Yrs document is malformed in a way that cannot be reconciled, it will mark the tree as "poisoned."
When a tree is poisoned, any operations on the tree that rely on the Yrs document will fail with a TreePoisoned
error. Operations that only rely on the tree's cached state will continue to succeed, but will not reflect the latest state of the Yrs document.
Example
use ;
use ;
See the examples folder in the repository for more.