pub struct AddWinsTree<T> { /* private fields */ }Expand description
Add-Wins Tree CRDT implementation
This implementation ensures that nodes are never completely lost. Deleted nodes are marked as deleted but preserved for potential recovery.
Implementations§
Source§impl<T: Clone + PartialEq + Eq + Send + Sync> AddWinsTree<T>
impl<T: Clone + PartialEq + Eq + Send + Sync> AddWinsTree<T>
Sourcepub fn with_config(replica: ReplicaId, config: TreeConfig) -> Self
pub fn with_config(replica: ReplicaId, config: TreeConfig) -> Self
Create with custom configuration
Sourcepub fn add_child(
&mut self,
parent_id: &NodeId,
value: T,
timestamp: u64,
) -> Result<NodeId, TreeError>
pub fn add_child( &mut self, parent_id: &NodeId, value: T, timestamp: u64, ) -> Result<NodeId, TreeError>
Add a child node
Sourcepub fn update(
&mut self,
id: &NodeId,
value: T,
timestamp: u64,
) -> Result<(), TreeError>
pub fn update( &mut self, id: &NodeId, value: T, timestamp: u64, ) -> Result<(), TreeError>
Update an existing node
Sourcepub fn remove(&mut self, id: &NodeId, timestamp: u64) -> Result<(), TreeError>
pub fn remove(&mut self, id: &NodeId, timestamp: u64) -> Result<(), TreeError>
Mark a node as deleted
Sourcepub fn move_node(
&mut self,
id: &NodeId,
new_parent_id: &NodeId,
) -> Result<(), TreeError>
pub fn move_node( &mut self, id: &NodeId, new_parent_id: &NodeId, ) -> Result<(), TreeError>
Move a node to a new parent
Sourcepub fn visible_nodes(&self) -> Vec<&TreeNode<T>>
pub fn visible_nodes(&self) -> Vec<&TreeNode<T>>
Get all visible nodes (not deleted)
Sourcepub fn descendants(&self, id: &NodeId) -> Vec<&TreeNode<T>>
pub fn descendants(&self, id: &NodeId) -> Vec<&TreeNode<T>>
Get descendants of a node (recursive)
Trait Implementations§
Source§impl<T: Clone + PartialEq + Eq + Send + Sync> CRDT for AddWinsTree<T>
impl<T: Clone + PartialEq + Eq + Send + Sync> CRDT for AddWinsTree<T>
fn replica_id(&self) -> &ReplicaId
Source§impl<T: Clone> Clone for AddWinsTree<T>
impl<T: Clone> Clone for AddWinsTree<T>
Source§fn clone(&self) -> AddWinsTree<T>
fn clone(&self) -> AddWinsTree<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T: Debug> Debug for AddWinsTree<T>
impl<T: Debug> Debug for AddWinsTree<T>
Source§impl<'de, T> Deserialize<'de> for AddWinsTree<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for AddWinsTree<T>where
T: Deserialize<'de>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<T: PartialEq> PartialEq for AddWinsTree<T>
impl<T: PartialEq> PartialEq for AddWinsTree<T>
Source§impl<T> Serialize for AddWinsTree<T>where
T: Serialize,
impl<T> Serialize for AddWinsTree<T>where
T: Serialize,
impl<T: Eq> Eq for AddWinsTree<T>
impl<T> StructuralPartialEq for AddWinsTree<T>
Auto Trait Implementations§
impl<T> Freeze for AddWinsTree<T>
impl<T> RefUnwindSafe for AddWinsTree<T>where
T: RefUnwindSafe,
impl<T> Send for AddWinsTree<T>where
T: Send,
impl<T> Sync for AddWinsTree<T>where
T: Sync,
impl<T> Unpin for AddWinsTree<T>where
T: Unpin,
impl<T> UnwindSafe for AddWinsTree<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more