Skip to main content

ToolHandler

Trait ToolHandler 

Source
pub trait ToolHandler: Send + Sync {
    // Required method
    fn handle<'life0, 'async_trait>(
        &'life0 self,
        args: Value,
        extra: RequestHandlerExtra,
    ) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn metadata(&self) -> Option<ToolInfo> { ... }
}
Expand description

Handler for tool execution.

Required Methods§

Source

fn handle<'life0, 'async_trait>( &'life0 self, args: Value, extra: RequestHandlerExtra, ) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Handle a tool call with the given arguments.

Provided Methods§

Source

fn metadata(&self) -> Option<ToolInfo>

Get tool metadata including description and schema. Returns None to use default empty metadata.

Implementors§

Source§

impl<F> ToolHandler for SimpleTool<F>
where F: Fn(Value, RequestHandlerExtra) -> Pin<Box<dyn Future<Output = Result<Value>> + Send>> + Send + Sync,

Available on non-WebAssembly only.
Source§

impl<F> ToolHandler for SyncTool<F>
where F: Fn(Value) -> Result<Value> + Send + Sync,

Available on non-WebAssembly only.
Source§

impl<T, F> ToolHandler for TypedSyncTool<T, F>
where T: DeserializeOwned + Send + Sync + 'static, F: Fn(T, RequestHandlerExtra) -> Result<Value> + Send + Sync,

Available on non-WebAssembly only.
Source§

impl<T, F> ToolHandler for TypedTool<T, F>
where T: DeserializeOwned + Send + Sync + 'static, F: Fn(T, RequestHandlerExtra) -> Pin<Box<dyn Future<Output = Result<Value>> + Send>> + Send + Sync,

Available on non-WebAssembly only.
Source§

impl<TIn, TOut, F> ToolHandler for TypedToolWithOutput<TIn, TOut, F>
where TIn: DeserializeOwned + Send + Sync + 'static, TOut: Serialize + Send + Sync + 'static, F: Fn(TIn, RequestHandlerExtra) -> Pin<Box<dyn Future<Output = Result<TOut>> + Send>> + Send + Sync,

Available on non-WebAssembly only.