Skip to main content

Handler

Trait Handler 

Source
pub trait Handler<M: Message>: Actor {
    // Required method
    fn handle(&mut self, msg: M, ctx: &Context<Self>) -> M::Result;
}
Expand description

Per-message handler trait. Implement once for each message type the actor handles.

Unlike the tasks version, handlers are synchronous — no async/.await.

Required Methods§

Source

fn handle(&mut self, msg: M, ctx: &Context<Self>) -> M::Result

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§