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§
Sourcefn methods(&self) -> &[MethodDef]
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.
Sourcefn execute(
&self,
primary: Option<&str>,
args: &[Arg],
input: Option<&PipeValue>,
) -> Result<CommandOutput, ExecutionError>
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 againstmethods.input— piped data from the previous command, if any.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".