pub trait ToolHandler<S>: Send + Sync {
type Args: DeserializeOwned + JsonSchema + 'static;
const ASKS_FOR_CONFIRMATION: bool = false;
// Required method
fn call<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
state: &'life1 S,
ctx: &'life2 RequestContext,
args: Self::Args,
) -> Pin<Box<dyn Future<Output = Result<ToolOutcome, ToolError>> + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
}Expand description
Implements one tool. S is the application state the protocol layer passes through, such as
the database pool, config and validator client.
Provided Associated Constants§
Sourceconst ASKS_FOR_CONFIRMATION: bool = false
const ASKS_FOR_CONFIRMATION: bool = false
Whether call can answer ToolOutcome::NeedsConfirmation. Only then does dispatch bind
the call’s arguments to a confirmation, which costs a pass over them.
Required Associated Types§
Sourcetype Args: DeserializeOwned + JsonSchema + 'static
type Args: DeserializeOwned + JsonSchema + 'static
The tool’s arguments; their JSON Schema is the tool’s input schema.
Required Methods§
fn call<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
state: &'life1 S,
ctx: &'life2 RequestContext,
args: Self::Args,
) -> Pin<Box<dyn Future<Output = Result<ToolOutcome, ToolError>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.