Skip to main content

Handler

Trait Handler 

Source
pub trait Handler<I>:
    Send
    + Sync
    + 'static {
    type Output: Send + Sync + 'static;

    // Required method
    fn handle(
        &self,
        input: I,
    ) -> impl Future<Output = Result<Self::Output>> + Send;
}
Expand description

Async domain transformation. Ordinary async functions and closures implement this. Use Emit<T> as the output with Subscription::new_emitting for 0/1/N output.

Subscriptions accept a handler whose input is the received record or its value, and whose output is the sink’s type or a plain value; see IntoHandler.

Required Associated Types§

Source

type Output: Send + Sync + 'static

Value published to the sink for each successfully handled input.

Required Methods§

Source

fn handle(&self, input: I) -> impl Future<Output = Result<Self::Output>> + Send

Process one decoded input.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<I, O, F, Fut> Handler<I> for F
where F: Fn(I) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<O>> + Send, O: Send + Sync + 'static,

Source§

impl<I, O, F> Handler<I> for Blocking<F>
where F: Fn(I) -> Result<O> + Send + Sync + 'static, I: Send + 'static, O: Send + Sync + 'static,