Skip to main content

Handler

Trait Handler 

Source
pub trait Handler<A, M>:
    Send
    + Sync
    + 'static { }
Expand description

Something that can handle A (an Event or a ConnectionState) together with the Client.

Implemented for

  • Fn(A, Client) -> impl Future<Output = ()>: |event, client| async move { .. }, run on the client’s event task;
  • Fn(A, Client): a plain closure, run on tokio’s blocking pool so it may block.

Handlers run one at a time, in arrival order. The marker M only tells the two apart.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl<A, F, Fut> Handler<A, (AsyncHandler, Fut)> for F
where A: Send + 'static, F: Fn(A, Client) -> Fut + Send + Sync + 'static, Fut: Future<Output = ()> + Send + 'static,