Trait HandlerWithContext

Source
pub trait HandlerWithContext<M: Message>
where M::Result: Send,
{ // Required method fn handle( &mut self, msg: M, ctx: &mut dyn DelayedActionRunner<Self>, ) -> M::Result; }
Expand description

Trait for handling a message with context. This is similar to the Handler trait, but it allows the handler to access the delayed action runner that is used to schedule actions to be run in the future. For actix::Actor, the context defined as actix::Context implements DelayedActionRunner. Note that the implementer for handler of a message only needs to implement either of Handler or HandlerWithContext, not both.

Required Methods§

Source

fn handle( &mut self, msg: M, ctx: &mut dyn DelayedActionRunner<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§

Source§

impl<A, M> HandlerWithContext<M> for A
where M: Message, A: Actor + Handler<M>, M::Result: Send,