capability-feature-measurement 0.1.0

A Rust crate providing a trait-based system for measuring and evaluating complexity, branching, density, and configuration of tree-like data structures.
Documentation
// ---------------- [ File: capability-feature-measurement/src/depth_breadth_density.rs ]
crate::ix!();

/// 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`, where `Xyz` aligns 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 return `None` or a default.

/// ---------------------------------------------------------------------------
/// 1) 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.
pub trait TreeDepthMeasurer {
    /// Returns the overall depth of this tree structure (≥1 if any nodes, 0 if empty).
    fn measure_tree_depth(&self) -> u8;
}

/// ---------------------------------------------------------------------------
/// 2) Breadth (Baseline Child Count)
/// ---------------------------------------------------------------------------

/// Provides a way to measure child counts (breadth) for each node in a tree structure.
pub trait TreeBreadthMeasurer {
    /// Returns the child-count distribution across all nodes in the tree (one entry per node).
    fn measure_tree_breadth_distribution(&self) -> Vec<u8>;
}

/// ---------------------------------------------------------------------------
/// 3) Density (Leaf Variants or Leaf Count)
/// ---------------------------------------------------------------------------

/// Provides a way to measure "leaf variants" or `leaf_count` at each node.
/// Some data structures track `leaf_count` explicitly; others might calculate it from subtrees.
pub trait TreeDensityMeasurer {
    /// Returns the leaf-count distribution across all nodes in the tree.
    fn measure_tree_density_distribution(&self) -> Vec<u16>;
}