Skip to main content

Handler

Trait Handler 

Source
pub trait Handler<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 Self: 'async_trait,
             'life0: '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 Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn init(&mut self, weak_client: WeakClient<P, S, R, E>) { ... }
    fn term(&mut self, rv: Option<RV>) -> Option<RV> { ... }
}
Available on crate feature tokio only.
Expand description

Message processing trait for an async handler.

See top module documentation for more information about application message handlers.

Required Methods§

Source

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