Skip to main content

IntoTypedHandler

Trait IntoTypedHandler 

Source
pub trait IntoTypedHandler<T, Args>:
    Send
    + Sync
    + 'static {
    type Future: Future<Output = Result<Handled, HandlerError>> + Send + 'static;

    // Required method
    fn call(&self, msg: T, ctx: MessageContext) -> Self::Future;
}
Expand description

A helper trait to allow registering handlers with or without context.

Required Associated Types§

Source

type Future: Future<Output = Result<Handled, HandlerError>> + Send + 'static

Required Methods§

Source

fn call(&self, msg: T, ctx: MessageContext) -> Self::Future

Implementors§

Source§

impl<F, Fut, T> IntoTypedHandler<T, (T, Result<Handled, ProcessingError>)> for F
where T: DeserializeOwned + Send + Sync + 'static, F: Fn(T) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<Handled, HandlerError>> + Send + 'static,

Implementation for standard closures returning Result<Handled, HandlerError>. This path is unique and allows correct inference for legacy code.

Source§

type Future = Fut

Source§

impl<F, Fut, T> IntoTypedHandler<T, (T, MessageContext, Result<Handled, ProcessingError>)> for F
where T: DeserializeOwned + Send + Sync + 'static, F: Fn(T, MessageContext) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<Handled, HandlerError>> + Send + 'static,

Source§

type Future = Fut

Source§

impl<F, Fut, T, R> IntoTypedHandler<T, (T, MessageContext, R)> for F
where T: DeserializeOwned + Send + Sync + 'static, R: ErgonomicResponse, F: Fn(T, MessageContext) -> Fut + Send + Sync + 'static, Fut: Future<Output = R> + Send + 'static,

Source§

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

Ergonomic implementation for closures returning types that implement ErgonomicResponse.