[][src]Trait xtra::Handler

pub trait Handler<M: Message>: Actor {
#[must_use]    fn handle<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        message: M,
        ctx: &'life1 mut Context<Self>
    ) -> Pin<Box<dyn Future<Output = M::Result> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
; }

A trait indicating that an Actor can handle a given Message asynchronously, and the logic to handle the message. If the message should be handled synchronously, then the SyncHandler trait should rather be implemented.

With the stable feature enabled, this is an async_trait, so implementations should be annotated #[async_trait].

Required methods

#[must_use]fn handle<'life0, 'life1, 'async_trait>(
    &'life0 mut self,
    message: M,
    ctx: &'life1 mut Context<Self>
) -> Pin<Box<dyn Future<Output = M::Result> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 

Handle a given message, returning its result.

With the stable feature enabled, this is an async_trait, so this method can be declared roughly as such:

This example is not tested
async fn handle(&mut self, message: M, ctx: &mut Context<Self>) -> M::Result
Loading content...

Implementors

impl<M: Message, T: SyncHandler<M> + Send> Handler<M> for T[src]

Loading content...