CommandHandler

Trait CommandHandler 

Source
pub trait CommandHandler {
    // Required method
    fn execute(&self, cli: &Cli) -> Result<()>;

    // Provided method
    fn parse_trees(&self, cli: &Cli) -> Result<(Vec<Tree>, Vec<Tree>)> { ... }
}
Expand description

Trait for command handlers - this makes the system extensible

Each command should implement this trait to provide its functionality. The trait receives the full CLI structure, allowing access to global options like the flamegraph file path and any command-specific parameters.

Required Methods§

Source

fn execute(&self, cli: &Cli) -> Result<()>

Execute the command with the given CLI arguments

§Arguments
  • cli - The parsed CLI arguments containing the flamegraph path and command details
§Returns
  • Result<()> - Success or a FerricError describing what went wrong

Provided Methods§

Source

fn parse_trees(&self, cli: &Cli) -> Result<(Vec<Tree>, Vec<Tree>)>

Parse flamegraph inputs into Tree structures for comparison

§Arguments
  • cli - The parsed CLI arguments containing flamegraph paths
§Returns
  • Result<(Vec<Tree>, Vec<Tree>)> - (primary_trees, comparison_trees)
    • primary_trees: Trees from -f input (1 file = 1 tree, directory = multiple trees)
    • comparison_trees: Trees from -c input (empty if no comparison)

Implementors§