pub struct TreeNode<T> {
pub id: NodeId,
pub value: T,
pub metadata: NodeMetadata,
pub parent: Option<NodeId>,
pub children: Vec<NodeId>,
}Expand description
A tree node with its metadata and relationships
Fields§
§id: NodeIdUnique identifier
value: TThe actual value
metadata: NodeMetadataMetadata
parent: Option<NodeId>Parent node ID (None for root)
children: Vec<NodeId>Child node IDs
Implementations§
Source§impl<T> TreeNode<T>
impl<T> TreeNode<T>
Sourcepub fn new_child(
value: T,
replica: ReplicaId,
timestamp: u64,
parent: NodeId,
) -> Self
pub fn new_child( value: T, replica: ReplicaId, timestamp: u64, parent: NodeId, ) -> Self
Create a child node
Sourcepub fn mark_modified(&mut self, replica: ReplicaId, timestamp: u64)
pub fn mark_modified(&mut self, replica: ReplicaId, timestamp: u64)
Mark as modified
Sourcepub fn mark_deleted(&mut self, replica: ReplicaId, timestamp: u64)
pub fn mark_deleted(&mut self, replica: ReplicaId, timestamp: u64)
Mark as deleted
Sourcepub fn remove_child(&mut self, child_id: &NodeId) -> bool
pub fn remove_child(&mut self, child_id: &NodeId) -> bool
Remove a child
Trait Implementations§
Source§impl<'de, T> Deserialize<'de> for TreeNode<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for TreeNode<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
impl<T: Eq> Eq for TreeNode<T>
impl<T> StructuralPartialEq for TreeNode<T>
Auto Trait Implementations§
impl<T> Freeze for TreeNode<T>where
T: Freeze,
impl<T> RefUnwindSafe for TreeNode<T>where
T: RefUnwindSafe,
impl<T> Send for TreeNode<T>where
T: Send,
impl<T> Sync for TreeNode<T>where
T: Sync,
impl<T> Unpin for TreeNode<T>where
T: Unpin,
impl<T> UnwindSafe for TreeNode<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