Skip to main content

Handler

Trait Handler 

Source
pub trait Handler<M>: Actor
where M: Message,
{ type Result: MessageResponse<Self, M>; // Required method fn handle( &mut self, msg: M, ctx: &mut Self::Context, ) -> impl Future<Output = Self::Result> + Send; }
Expand description

Describes how an actor handles a specific message type.

Required Associated Types§

Source

type Result: MessageResponse<Self, M>

The return type of the handler, which must implement MessageResponse.

Required Methods§

Source

fn handle( &mut self, msg: M, ctx: &mut Self::Context, ) -> impl Future<Output = Self::Result> + Send

Handles a message.

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> Handler<CronSignal> for A

Available on crate feature cron only.
Source§

impl<A> Handler<Signal> for A
where A: Actor, A::Context: ActorContext<A>,

Source§

impl<A> Handler<Supervisor<A>> for A
where A: Actor, A::Context: ActorContext<A>,

Source§

impl<A, M> Handler<Observer<M>> for A
where A: SubjectActor<M>, M: Message + Clone,

Available on crate feature observer only.