Message

Trait Message 

Source
pub trait Message:
    Any
    + Send
    + Sized
    + 'static {
    // Provided methods
    fn from_boxed(m: BoxedMessage) -> Result<Self, BoxedDowncastErr> { ... }
    fn box_message(
        self,
        pid: &ActorId,
    ) -> Result<BoxedMessage, BoxedDowncastErr> { ... }
}
Expand description

Message type for an actor. Generally an enum which muxes the various types of inner-messages the actor supports

§Example

pub enum MyMessage {
    /// Record the name to the actor state
    RecordName(String),
    /// Print the recorded name from the state to command line
    PrintName,
}

Provided Methods§

Source

fn from_boxed(m: BoxedMessage) -> Result<Self, BoxedDowncastErr>

Convert a BoxedMessage to this concrete type

Source

fn box_message(self, pid: &ActorId) -> Result<BoxedMessage, BoxedDowncastErr>

Convert this message to a BoxedMessage

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<T: Any + Send + Sized + 'static> Message for T

Available on non-crate feature cluster only.