pub trait Tool: Send + Sync {
type Input: DeserializeOwned + JsonSchema + Send + Sync + 'static;
type Output: Serialize + Send + Sync;
// Required method
fn invoke<'life0, 'async_trait>(
&'life0 self,
input: Self::Input,
) -> Pin<Box<dyn Future<Output = Result<Self::Output, ToolError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided method
fn args_schema(&self) -> Option<Value> { ... }
}Expand description
Generic tool trait (type-safe version).
For scenarios requiring type-safe input/output. Tools implementing this trait can be automatically wrapped as BaseTool.
Required Associated Types§
Sourcetype Input: DeserializeOwned + JsonSchema + Send + Sync + 'static
type Input: DeserializeOwned + JsonSchema + Send + Sync + 'static
Input type (must support deserialization and JSON Schema).
Required Methods§
Provided Methods§
Sourcefn args_schema(&self) -> Option<Value>
fn args_schema(&self) -> Option<Value>
Returns the input JSON Schema.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".