CommandHandler

Trait CommandHandler 

Source
pub trait CommandHandler:
    Send
    + Sync
    + 'static {
    // Required method
    fn execute(&mut self, app: &mut TerminalApp, args: &[&str]) -> String;
}
Expand description

Trait for synchronous command handlers that can be registered with the terminal application.

All synchronous commands must implement this trait to be executable within the terminal app. Handlers receive mutable access to the application state and command arguments.

Required Methods§

Source

fn execute(&mut self, app: &mut TerminalApp, args: &[&str]) -> String

Executes the command with the given application state and arguments.

§Arguments
  • app - Mutable reference to the terminal application
  • args - Slice of command arguments
§Returns

String output to be displayed to the user

Implementors§

Source§

impl<F> CommandHandler for F
where F: FnMut(&mut TerminalApp, &[&str]) -> String + Send + Sync + 'static,

Blanket implementation of CommandHandler for closures.

This allows simple closures to be used as command handlers without explicitly implementing the trait.