pub trait Handler<S, R, E, RV> {
// Required method
fn proc_req(
&mut self,
msg: S,
rctx: ReplyContext<R, E>,
) -> ControlFlow<RV, ()>;
// Provided methods
fn init(&mut self, weak_client: WeakClient<S, R, E>) { ... }
fn term(&mut self, rv: Option<RV>) -> Option<RV> { ... }
}
Expand description
Message processing trait for a threaded handler.
Required Methods§
Sourcefn proc_req(&mut self, msg: S, rctx: ReplyContext<R, E>) -> ControlFlow<RV, ()>
fn proc_req(&mut self, msg: S, rctx: ReplyContext<R, E>) -> ControlFlow<RV, ()>
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§
Sourcefn init(&mut self, weak_client: WeakClient<S, R, E>)
fn init(&mut self, weak_client: WeakClient<S, R, E>)
Optional initialization callback.
This is called on the dispatcher thread before the main message dispatch loop is entered.
Sourcefn term(&mut self, rv: Option<RV>) -> Option<RV>
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 terminated.
The rv
argument is set to the return value returned from the dispatcher
loop. It will be set to Some()
value if a request handler returned
ControlFlow::Break(RV)
. If will be set to None
if the dispatch loop
terminated because the queue is empty and all of the linked clients have
been dropped.
The value returned from this callback is returned from the dispatcher thread when it is joined.
The default implementation simply returns the rv
parameter.