Skip to main content

ToolDyn

Trait ToolDyn 

Source
pub trait ToolDyn: WasmCompatSend + WasmCompatSync {
    // Required methods
    fn name(&self) -> &str;
    fn definition(&self) -> ToolDefinition;
    fn call_dyn<'a>(
        &'a self,
        input: Value,
        ctx: &'a ToolContext,
    ) -> WasmBoxedFuture<'a, Result<ToolOutput, ToolError>>;
}
Expand description

Type-erased tool for dynamic dispatch. Blanket-implemented for all Tool impls.

This enables heterogeneous tool collections (HashMap<String, Arc<dyn ToolDyn>>) while preserving type safety at the implementation level.

Required Methods§

Source

fn name(&self) -> &str

The tool’s unique name.

Source

fn definition(&self) -> ToolDefinition

The tool definition (name, description, input schema).

Source

fn call_dyn<'a>( &'a self, input: Value, ctx: &'a ToolContext, ) -> WasmBoxedFuture<'a, Result<ToolOutput, ToolError>>

Execute the tool with a JSON value input, returning a generic output.

Implementors§

Source§

impl<T: Tool> ToolDyn for T

Blanket implementation: any Tool automatically becomes a ToolDyn.

Handles:

  • Deserializing serde_json::Value into T::Args
  • Calling T::call(args, ctx)
  • Serializing T::Output into ToolOutput
  • Mapping T::Error into ToolError::ExecutionFailed