actix

Trait Handler

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

Describes how to handle messages of a specific type.

Implementing Handler is a general way to handle incoming messages, streams, and futures.

The type M is a message which can be handled by the actor.

Required Associated Types§

Source

type Result: MessageResponse<Self, M>

The type of value that this handler will return.

Check the MessageResponse trait for some details on how a message can be responded to.

Required Methods§

Source

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

This method is called for every message received by this actor.

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<M, T: Sized + Unpin + 'static> Handler<M> for Mocker<T>
where M: Message + 'static, <M as Message>::Result: MessageResponse<Mocker<T>, M>,