Actor

Trait Actor 

Source
pub trait Actor: Sized {
    type Message;

    // Required method
    async fn on_mount<M>(&mut self, _: DynamicAddress<Self::Message>, _: M) -> !
       where M: Inbox<Self::Message>;
}
Expand description

Trait that each actor must implement. An actor defines a message type that it acts on, and an implementation of on_mount which is invoked when the actor is started.

At run time, an Actor is held within an ActorContext, which contains the embassy task and the message queues. The size of the message queue is configured per ActorContext.

Required Associated Types§

Source

type Message

The message type that this actor expects to receive from its inbox.

Required Methods§

Source

async fn on_mount<M>(&mut self, _: DynamicAddress<Self::Message>, _: M) -> !
where M: Inbox<Self::Message>,

Called when an actor is mounted (activated). The actor will be provided with the address to itself, and an inbox used to receive incoming messages.

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§