pub struct Tree {
pub nodes: HashMap<Uuid, TreeNode>,
pub roots: Vec<Uuid>,
pub total_samples: u64,
}Expand description
A hierarchical tree structure containing TreeNodes with UUID-based relationships
Fields§
§nodes: HashMap<Uuid, TreeNode>All nodes in the tree indexed by their UUID
roots: Vec<Uuid>Root node UUIDs (nodes with no parent)
total_samples: u64Total samples from the flamegraph SVG for percentage calculations
Implementations§
Source§impl Tree
impl Tree
Sourcepub fn from_parser_nodes(
parser_nodes: Vec<ParserNode>,
_total_samples: u64,
) -> Self
pub fn from_parser_nodes( parser_nodes: Vec<ParserNode>, _total_samples: u64, ) -> Self
Create a new Tree from a vector of ParserNodes
Sourcepub fn calculate_self_sample_counts(&mut self)
pub fn calculate_self_sample_counts(&mut self)
Calculate self_sample_count for all nodes in the tree self_sample_count = inclusive sample_count - sum of children’s inclusive sample_counts
Sourcepub fn calculate_total_samples(&mut self)
pub fn calculate_total_samples(&mut self)
Calculate total_samples from the sum of all root nodes’ sample_count This reflects the actual total samples in the flamegraph more accurately than relying on the SVG total_samples attribute
Sourcepub fn get_node_mut(&mut self, id: Uuid) -> Option<&mut TreeNode>
pub fn get_node_mut(&mut self, id: Uuid) -> Option<&mut TreeNode>
Get a mutable node by UUID
Sourcepub fn get_children(&self, node_id: Uuid) -> Vec<&TreeNode>
pub fn get_children(&self, node_id: Uuid) -> Vec<&TreeNode>
Get children of a node
Sourcepub fn get_parent(&self, node_id: Uuid) -> Option<&TreeNode>
pub fn get_parent(&self, node_id: Uuid) -> Option<&TreeNode>
Get parent of a node
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Get total number of nodes in the tree
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Tree
impl<'de> Deserialize<'de> for Tree
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 Tree
impl RefUnwindSafe for Tree
impl Send for Tree
impl Sync for Tree
impl Unpin for Tree
impl UnwindSafe for Tree
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