pub trait Tool {
// Required method
fn call<'life0, 'async_trait>(
&'life0 self,
args: String,
) -> Pin<Box<dyn Future<Output = String> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided methods
fn call_timed<'life0, 'async_trait>(
&'life0 self,
call: ToolCall,
) -> Pin<Box<dyn Future<Output = ToolResult> + Send + 'async_trait>>
where Self: Sync + 'async_trait,
'life0: 'async_trait { ... }
fn call_batch<'life0, 'async_trait>(
&'life0 self,
args: Vec<ToolCall>,
) -> Pin<Box<dyn Future<Output = Vec<ToolResult>> + Send + 'async_trait>>
where Self: Sync + 'async_trait,
'life0: 'async_trait { ... }
}Expand description
A trait for tools that can be called with JSON string arguments.
Users must provide the call method. The framework auto-provides call_batch to run tools in parallel.
At runtime, different tool executors may call call or call_batch in different ways.
Users can override call_batch to customize this behavior.
Required Methods§
Provided Methods§
Sourcefn call_timed<'life0, 'async_trait>(
&'life0 self,
call: ToolCall,
) -> Pin<Box<dyn Future<Output = ToolResult> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn call_timed<'life0, 'async_trait>(
&'life0 self,
call: ToolCall,
) -> Pin<Box<dyn Future<Output = ToolResult> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
Calls the tool with timing measurement