pub trait ToolCodec<T: Tool>:
Send
+ Sync
+ 'static {
type WireIn: DeserializeOwned + JsonSchema + Send + 'static;
type WireOut: Serialize + JsonSchema + Send + 'static;
// Required methods
fn decode(wire: Self::WireIn) -> Result<T::Input, ToolError>;
fn encode(native: T::Output) -> Result<Self::WireOut, ToolError>;
}Expand description
Codec for serializing tool inputs/outputs at protocol boundaries.
Serde and schemars bounds reside here, NOT on the Tool trait.
This keeps native Rust calls zero-serialization while supporting
MCP, napi, and provider schema generation.
§Identity Codec
When T::Input and T::Output already implement the required serde/schemars
traits, use () as the codec (blanket implementation provided).
Required Associated Types§
Sourcetype WireIn: DeserializeOwned + JsonSchema + Send + 'static
type WireIn: DeserializeOwned + JsonSchema + Send + 'static
Wire format for input (must be deserializable and have JSON schema).
Sourcetype WireOut: Serialize + JsonSchema + Send + 'static
type WireOut: Serialize + JsonSchema + Send + 'static
Wire format for output (must be serializable and have JSON schema).
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl<T> ToolCodec<T> for ()
Identity codec: when Input/Output already have serde/schemars, use () as codec.
impl<T> ToolCodec<T> for ()
Identity codec: when Input/Output already have serde/schemars, use () as codec.