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,

Source§

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