Trait Handler

Source
pub trait Handler<P, S, R, E, RV> {
    // Required methods
    fn post(&mut self, msg: P) -> ControlFlow<RV>;
    fn req(&mut self, msg: S, rctx: ReplyContext<R, E>) -> ControlFlow<RV>;

    // 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 a threaded handler.

Required Methods§

Source

fn post(&mut self, msg: P) -> ControlFlow<RV>

Post 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 thread.

Source

fn req(&mut self, msg: S, rctx: ReplyContext<R, E>) -> ControlFlow<RV>

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 thread.

Provided Methods§

Source

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

Optional initialization callback.

This is called on the dispatcher thread 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 thread just after the main message processing loop has been terminbated.

Implementors§