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§
Sourcefn start_actor(&mut self, _ctx: &mut dyn DelayedActionRunner<Self>)
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.
Sourcefn 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 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.
Sourcefn stop_actor(&mut self)
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.