Skip to main content

SlashCommand

Trait SlashCommand 

Source
pub trait SlashCommand: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn methods(&self) -> &[MethodDef];
    fn execute(
        &self,
        primary: Option<&str>,
        args: &[Arg],
        input: Option<&PipeValue>,
    ) -> Result<CommandOutput, ExecutionError>;
}
Expand description

Port: a self-contained tool that knows its own methods.

Each implementor is a builtin command (e.g. /read, /exec, /find). The registry holds these as Box<dyn SlashCommand> and dispatches by name.

Required Methods§

Source

fn name(&self) -> &str

The command’s registered name (e.g. "read", "exec").

Source

fn methods(&self) -> &[MethodDef]

The methods this command accepts.

The registry validates all .method() args against this list before calling execute. Unknown methods are rejected with a clear error message.

Source

fn execute( &self, primary: Option<&str>, args: &[Arg], input: Option<&PipeValue>, ) -> Result<CommandOutput, ExecutionError>

Execute the command.

  • primary — the value from /cmd(value) syntax, if present.
  • args — builder-chain methods, already validated against methods.
  • input — piped data from the previous command, if any.

Implementors§