pub struct TreeNode {
pub id: String,
pub label: String,
pub node_type: String,
pub children: Vec<TreeNode>,
pub attributes: HashMap<String, String>,
pub size: Option<Size>,
}Expand description
Tree node for visualization.
Fields§
§id: StringUnique identifier for the node.
label: StringDisplay label for the node.
node_type: StringType of the node (e.g., “node”, “leaf”, “function”, “struct”).
children: Vec<TreeNode>Child nodes of this node.
attributes: HashMap<String, String>Additional metadata associated with the node.
size: Option<Size>Optional explicit size for the node.
Implementations§
Source§impl TreeNode
impl TreeNode
Sourcepub fn with_child(self, child: TreeNode) -> Self
pub fn with_child(self, child: TreeNode) -> Self
Adds a child to the node and returns the modified node.
Sourcepub fn with_children(self, children: Vec<TreeNode>) -> Self
pub fn with_children(self, children: Vec<TreeNode>) -> Self
Sets the children of the node and returns the modified node.
Sourcepub fn with_attribute(self, key: String, value: String) -> Self
pub fn with_attribute(self, key: String, value: String) -> Self
Adds an attribute to the node and returns the modified node.
Sourcepub fn with_size(self, size: Size) -> Self
pub fn with_size(self, size: Size) -> Self
Sets the size of the node and returns the modified node.
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Calculates the total number of nodes in the tree rooted at this node.
Sourcepub fn leaf_count(&self) -> usize
pub fn leaf_count(&self) -> usize
Calculates the total number of leaf nodes in the tree rooted at this node.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for TreeNode
impl<'de> Deserialize<'de> for TreeNode
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
Auto Trait Implementations§
impl Freeze for TreeNode
impl RefUnwindSafe for TreeNode
impl Send for TreeNode
impl Sync for TreeNode
impl Unpin for TreeNode
impl UnsafeUnpin for TreeNode
impl UnwindSafe for TreeNode
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