pub trait ToolHandler: Send + Sync {
// Required methods
fn kind(&self) -> ToolKind;
fn handle<'life0, 'async_trait>(
&'life0 self,
invocation: ToolInvocation,
) -> Pin<Box<dyn Future<Output = Result<ToolOutput, FunctionCallError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided methods
fn matches_kind(&self, kind: ToolKind) -> bool { ... }
fn is_mutating(&self) -> bool { ... }
}Expand description
Trait implemented by concrete tool handlers.
Each registered tool is backed by a handler that reports its kind, whether it is mutating, and performs the actual execution.
Required Methods§
Sourcefn handle<'life0, 'async_trait>(
&'life0 self,
invocation: ToolInvocation,
) -> Pin<Box<dyn Future<Output = Result<ToolOutput, FunctionCallError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn handle<'life0, 'async_trait>(
&'life0 self,
invocation: ToolInvocation,
) -> Pin<Box<dyn Future<Output = Result<ToolOutput, FunctionCallError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Execute the tool with the given invocation context.
Provided Methods§
Sourcefn matches_kind(&self, kind: ToolKind) -> bool
fn matches_kind(&self, kind: ToolKind) -> bool
Returns true if kind matches this handler’s expected kind.
The default implementation compares against kind().
Sourcefn is_mutating(&self) -> bool
fn is_mutating(&self) -> bool
Whether this tool performs side-effects that require user approval.
Defaults to false (read-only / safe).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".