Skip to main content

Message

Trait Message 

Source
pub trait Message: 'static + Send {
    type Response: 'static + Send;
}
Expand description

Anything that you want to send to an actor.

Messages can have a response type like Ping and Pong in the following example.

#[message(response = Pong)]
struct Ping;

struct Pong; // does not need to implement `Message`

Or they can be fire-and-forget messages like Stop in the following example.

#[message]
struct Store(&'static str);

You can also derive the Message trait for simple messages without a response.

#[derive(Debug, Message)]
struct Store(&'static str);

Required Associated Types§

Source

type Response: 'static + Send

What the actor should respond with.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Message for ()

Implementors§