Trait AsyncHandler

Source
pub trait AsyncHandler<P, S, R, E, RV> {
    // Required methods
    fn post<'life0, 'async_trait>(
        &'life0 mut self,
        msg: P,
    ) -> Pin<Box<dyn Future<Output = ControlFlow<RV>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn req<'life0, 'async_trait>(
        &'life0 mut self,
        msg: S,
        rctx: ReplyContext<R, E>,
    ) -> Pin<Box<dyn Future<Output = ControlFlow<RV>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;

    // Provided methods
    fn init(&mut self, weak_client: Weak<P, S, R, E>) { ... }
    fn term(&mut self, rv: Option<RV>) -> Option<RV> { ... }
}
Expand description

Message processing trait for an async handler.

Required Methods§

Source

fn post<'life0, 'async_trait>( &'life0 mut self, msg: P, ) -> Pin<Box<dyn Future<Output = ControlFlow<RV>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Put message processing callback.

The callback must return ControlFlow::Continue(()) to keep the dispatcher loop going. Returning ControlFlow::Break(RV) will cause the dispatcher loop to abort and returns the value in RV from the task.

Source

fn req<'life0, 'async_trait>( &'life0 mut self, msg: S, rctx: ReplyContext<R, E>, ) -> Pin<Box<dyn Future<Output = ControlFlow<RV>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Request message processing callback.

The callback must return ControlFlow::Continue(()) to keep the dispatcher loop going. Returning ControlFlow::Break(RV) will cause the dispatcher loop to abort and returns the value in RV from the task.

Provided Methods§

Source

fn init(&mut self, weak_client: Weak<P, S, R, E>)

Optional initialization callback.

This is called on the dispatcher task before the main message processing loop is entered.

Source

fn term(&mut self, rv: Option<RV>) -> Option<RV>

Optional termination callback.

This is called on the dispatcher task just after the main message processing loop has been terminbated.

Implementors§