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 ExecContext,
) -> Pin<Box<dyn Future<Output = ExecResult> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided method
fn validate(&self, args: &ToolArgs) -> Vec<ValidationIssue> { ... }
}Expand description
A tool that can be executed.
Required Methods§
Sourcefn schema(&self) -> ToolSchema
fn schema(&self) -> ToolSchema
Get the tool’s schema.
Sourcefn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
args: ToolArgs,
ctx: &'life1 mut ExecContext,
) -> Pin<Box<dyn Future<Output = ExecResult> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
args: ToolArgs,
ctx: &'life1 mut ExecContext,
) -> Pin<Box<dyn Future<Output = ExecResult> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Execute the tool with the given arguments and context.
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".