ratatui_toolkit/primitives/tree_view/tree_node/
mod.rs

1//! Tree node type for hierarchical data representation.
2
3mod constructors;
4
5/// A node in the tree.
6///
7/// Represents a single node with data and optional children.
8/// Each node can be marked as expandable (has children) for proper
9/// UI rendering of expand/collapse indicators.
10///
11/// # Type Parameters
12///
13/// * `T` - The type of data stored in the node.
14///
15/// # Example
16///
17/// ```rust
18/// use ratatui_toolkit::tree_view::TreeNode;
19///
20/// let leaf = TreeNode::new("Leaf");
21/// let parent = TreeNode::with_children("Parent", vec![leaf]);
22/// ```
23#[derive(Debug, Clone)]
24pub struct TreeNode<T> {
25    /// Node data
26    pub data: T,
27    /// Child nodes
28    pub children: Vec<TreeNode<T>>,
29    /// Whether this node can be expanded (has children)
30    pub expandable: bool,
31}