pub trait Tool: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn schema(&self) -> ToolSchema;
fn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
args: ToolArgs,
ctx: &'life1 mut dyn ToolCtx,
) -> Pin<Box<dyn Future<Output = ExecResult> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
// Provided method
fn validate(&self, args: &ToolArgs) -> Vec<ValidationIssue> { ... }
}Expand description
A tool that can be executed.
Every kaish command — builtin or third-party — implements this trait. The
execute method receives a &mut dyn ToolCtx, the trimmed portable
context; tools needing deeper kernel state downcast via
ToolCtx::as_any_mut.
Required Methods§
Sourcefn schema(&self) -> ToolSchema
fn schema(&self) -> ToolSchema
Get the tool’s schema.
Provided Methods§
Sourcefn validate(&self, args: &ToolArgs) -> Vec<ValidationIssue>
fn validate(&self, args: &ToolArgs) -> Vec<ValidationIssue>
Validate arguments without executing.
Default implementation validates against the schema. Override this for semantic checks (regex validity, zero increment, etc.).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".