Trait Message

Source
pub trait Message<T: Send + 'static>: Actor {
    type Reply: Send + 'static;

    // Required method
    fn handle(
        &mut self,
        msg: T,
        actor_ref: &ActorRef,
    ) -> impl Future<Output = Self::Reply> + Send;
}
Expand description

A trait for messages that an actor can handle, defining the reply type.

An actor struct implements this trait for each specific message type it can process.

Required Associated Types§

Source

type Reply: Send + 'static

The type of the reply that will be sent back to the caller.

Required Methods§

Source

fn handle( &mut self, msg: T, actor_ref: &ActorRef, ) -> impl Future<Output = Self::Reply> + Send

Handles the incoming message and produces a reply.

The actor_ref parameter is a reference to the actor’s own ActorRef. This is an asynchronous method where the actor’s business logic for processing the message T resides.

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§