pub trait TreeDepthMeasurer {
// Required method
fn measure_tree_depth(&self) -> u8;
}Expand description
We want to define a trait hierarchy for “measuring” each portion of a GrowerTreeConfiguration
against arbitrary tree-like data structures (e.g., Skeleton, StringSkeleton, or others).
These traits let us measure or infer the real state of a tree structure, so that client code can compare “actual” vs. “expected” parameters in a generic way.
Naming Conventions:
- Each trait is named
TreeXyzMeasurer, whereXyzaligns with a portion of the config. - Each trait method is named
measure_tree_xyz(...). - Associated data types similarly use
TreeXyz...naming, with no public fields. Instead, we rely on private fields with accessor methods as needed (getset/derive_builder).
Implementation Strategy:
- For each data structure type (e.g.,
Skeleton,StringSkeleton), implement these traits to provide the correct measurements. - Some parameters (like
leaf_granularity, etc.) might be purely derived from config or environment, so the measurement method can returnNoneor a default.
- Depth
Provides a way to measure the maximum depth of a tree-like structure.
Implementations might do BFS/DFS to compute the maximum path length from root to leaves.
Required Methods§
Sourcefn measure_tree_depth(&self) -> u8
fn measure_tree_depth(&self) -> u8
Returns the overall depth of this tree structure (≥1 if any nodes, 0 if empty).