Actor

Trait Actor 

Source
pub trait Actor {
    // Provided methods
    fn start_actor(&mut self, _ctx: &mut dyn DelayedActionRunner<Self>) { ... }
    fn wrap_handler<M, R>(
        &mut self,
        msg: M,
        ctx: &mut dyn DelayedActionRunner<Self>,
        f: impl FnOnce(&mut Self, M, &mut dyn DelayedActionRunner<Self>) -> R,
    ) -> R { ... }
    fn stop_actor(&mut self) { ... }
}
Expand description

Trait for an actor. An actor is a struct that can handle messages and implements the Handler or HandlerWithContext trait.

IMPORTANT NOTE: For the Multithread actor runtime, NONE of the below methods are ever called. These are only applicable for the async tokio runtime.

Provided Methods§

Source

fn start_actor(&mut self, _ctx: &mut dyn DelayedActionRunner<Self>)

This is automatically called by the actor runtime when the actor is started. It is called before any messages are processed.

Source

fn wrap_handler<M, R>( &mut self, msg: M, ctx: &mut dyn DelayedActionRunner<Self>, f: impl FnOnce(&mut Self, M, &mut dyn DelayedActionRunner<Self>) -> R, ) -> R

This is called for every message that the actor handles, so that the actor can do something else before and after handling the message.

Source

fn stop_actor(&mut self)

Called by the actor runtime right before the actor is dropped.

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§