pub struct TypedTool<H>(pub H);Expand description
Wraps a typed ToolHandler as a type-erased DynTool.
This adapter is where erasure happens for native Rust tools:
call_json deserializes the incoming Value into the
handler’s Input, calls the typed handler, and serializes its Output back
to a Value. A Suspension passes through untouched.
A newtype wrapper is used rather than a blanket impl<H: ToolHandler> DynTool for H, so that MCP-backed tools remain free to implement DynTool
directly for their own types without a coherence conflict.
ToolSet::register wraps handlers in this
automatically, so most callers never name it.
Tuple Fields§
§0: HImplementations§
Trait Implementations§
Source§impl<H: ToolHandler> DynTool for TypedTool<H>
impl<H: ToolHandler> DynTool for TypedTool<H>
Source§fn idempotency_key(&self, input: &Value) -> Option<String>
fn idempotency_key(&self, input: &Value) -> Option<String>
Forwards to the typed ToolHandler::idempotency_key, which sees the
deserialized input rather than raw JSON.
The input is deserialized a second time here, once per keyed dispatch,
because the key is needed before
call_json runs and that is where the first
deserialization happens. Input that does not deserialize yields None:
the dispatch below is about to reject it as
ToolError::InvalidInput anyway, and a
call that cannot run has no effect to name.
Source§fn description(&self) -> &str
fn description(&self) -> &str
Source§fn input_schema(&self) -> Value
fn input_schema(&self) -> Value
Source§fn output_schema(&self) -> Option<Value>
fn output_schema(&self) -> Option<Value>
None, so no existing
implementor of this trait breaks. Read more