pub trait Actor:
Sized
+ Send
+ 'static {
type Msg: Send + 'static;
// Required method
fn handle<'life0, 'life1, 'async_trait>(
&'life0 mut self,
ctx: &'life1 mut Context<Self>,
msg: Self::Msg,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided methods
fn pre_start<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_ctx: &'life1 mut Context<Self>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn post_stop<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_ctx: &'life1 mut Context<Self>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn pre_restart<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
_ctx: &'life1 mut Context<Self>,
_err: &'life2 str,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn post_restart<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
_ctx: &'life1 mut Context<Self>,
_err: &'life2 str,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn supervisor_strategy(&self) -> SupervisorStrategy { ... }
}Expand description
The user-facing Actor trait.
is expressed here as: each actor has an
associated Msg type (typically an enum) and implements an async
handle that matches on it.
Required Associated Types§
Required Methods§
Provided Methods§
Sourcefn pre_start<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_ctx: &'life1 mut Context<Self>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn pre_start<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_ctx: &'life1 mut Context<Self>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Called once before the first message.
Sourcefn post_stop<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_ctx: &'life1 mut Context<Self>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn post_stop<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_ctx: &'life1 mut Context<Self>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Called after the actor has been stopped.
Sourcefn pre_restart<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
_ctx: &'life1 mut Context<Self>,
_err: &'life2 str,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn pre_restart<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
_ctx: &'life1 mut Context<Self>,
_err: &'life2 str,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Called when the actor is about to be restarted by the supervisor.
Sourcefn post_restart<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
_ctx: &'life1 mut Context<Self>,
_err: &'life2 str,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn post_restart<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
_ctx: &'life1 mut Context<Self>,
_err: &'life2 str,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Called after a restart.
Sourcefn supervisor_strategy(&self) -> SupervisorStrategy
fn supervisor_strategy(&self) -> SupervisorStrategy
The supervisor strategy this actor applies to its own children.
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.