Skip to main content

ExtractorHandler

Trait ExtractorHandler 

Source
pub trait ExtractorHandler<S, T>:
    Clone
    + Send
    + Sync
    + 'static {
    type Future: Future<Output = Result<CallToolResult>> + Send;

    // Required methods
    fn call(self, ctx: RequestContext, state: S, args: Value) -> Self::Future;
    fn input_schema() -> Value;
}
Expand description

A handler that uses extractors.

This trait is implemented for functions that take extractors as arguments. You don’t need to implement this trait directly; it’s automatically implemented for compatible async functions.

Required Associated Types§

Source

type Future: Future<Output = Result<CallToolResult>> + Send

The future returned by the handler.

Required Methods§

Source

fn call(self, ctx: RequestContext, state: S, args: Value) -> Self::Future

Call the handler with extracted values.

Source

fn input_schema() -> Value

Get the input schema for this handler.

Returns None if no Json<T> extractor is used.

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<S, F, Fut, T1> ExtractorHandler<S, (T1,)> for F
where S: Clone + Send + Sync + 'static, F: Fn(T1) -> Fut + Clone + Send + Sync + 'static, Fut: Future<Output = Result<CallToolResult>> + Send, T1: FromToolRequest<S> + Send,

Source§

impl<S, F, Fut, T1, T2> ExtractorHandler<S, (T1, T2)> for F
where S: Clone + Send + Sync + 'static, F: Fn(T1, T2) -> Fut + Clone + Send + Sync + 'static, Fut: Future<Output = Result<CallToolResult>> + Send, T1: FromToolRequest<S> + Send, T2: FromToolRequest<S> + Send,

Source§

impl<S, F, Fut, T1, T2, T3> ExtractorHandler<S, (T1, T2, T3)> for F
where S: Clone + Send + Sync + 'static, F: Fn(T1, T2, T3) -> Fut + Clone + Send + Sync + 'static, Fut: Future<Output = Result<CallToolResult>> + Send, T1: FromToolRequest<S> + Send, T2: FromToolRequest<S> + Send, T3: FromToolRequest<S> + Send,

Source§

impl<S, F, Fut, T1, T2, T3, T4> ExtractorHandler<S, (T1, T2, T3, T4)> for F
where S: Clone + Send + Sync + 'static, F: Fn(T1, T2, T3, T4) -> Fut + Clone + Send + Sync + 'static, Fut: Future<Output = Result<CallToolResult>> + Send, T1: FromToolRequest<S> + Send, T2: FromToolRequest<S> + Send, T3: FromToolRequest<S> + Send, T4: FromToolRequest<S> + Send,

Source§

impl<S, F, Fut, T1, T2, T3, T4, T5> ExtractorHandler<S, (T1, T2, T3, T4, T5)> for F
where S: Clone + Send + Sync + 'static, F: Fn(T1, T2, T3, T4, T5) -> Fut + Clone + Send + Sync + 'static, Fut: Future<Output = Result<CallToolResult>> + Send, T1: FromToolRequest<S> + Send, T2: FromToolRequest<S> + Send, T3: FromToolRequest<S> + Send, T4: FromToolRequest<S> + Send, T5: FromToolRequest<S> + Send,