Skip to main content

ToolHandler

Trait ToolHandler 

Source
pub trait ToolHandler<Marker>:
    Clone
    + Send
    + Sync
    + 'static {
    // Required method
    fn into_handler_fn(self) -> ToolHandlerFn;
}
Expand description

Implemented for async functions that can serve as tool handlers.

Supports two calling conventions:

  1. |args: serde_json::Value| async { ... } – raw JSON args
  2. |params: MyStruct| async { ... } – typed, deserialized args

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.

Implementors§

Source§

impl<F, Fut, R, T> ToolHandler<AuthenticatedMarker<T>> for F
where F: Fn(T, Auth) -> Fut + Clone + Send + Sync + 'static, Fut: Future<Output = R> + Send + 'static, R: IntoToolResult + Send + 'static, T: DeserializeOwned + Send + 'static,

Available on crate feature auth only.
Source§

impl<F, Fut, R, T> ToolHandler<TypedMarker<T>> for F
where F: Fn(T) -> Fut + Clone + Send + Sync + 'static, Fut: Future<Output = R> + Send + 'static, R: IntoToolResult + Send + 'static, T: DeserializeOwned + Send + 'static,