pub trait Actor: Sized + 'static {
type State: 'static;
type Arguments: Send + 'static;
type Error: Send + 'static;
// Required method
async fn pre_start(
&self,
myself: &Mailbox<Self>,
arguments: Self::Arguments,
) -> Result<Self::State, Self::Error>;
// Provided methods
async fn post_start(
&self,
_myself: &Mailbox<Self>,
_state: &mut Self::State,
) -> Result<(), Self::Error> { ... }
async fn pre_stop(
&self,
_myself: &Mailbox<Self>,
_state: &mut Self::State,
) -> Result<(), Self::Error> { ... }
async fn post_stop(
&self,
_myself: &Mailbox<Self>,
_state: &mut Self::State,
) -> Result<(), Self::Error> { ... }
}Available on crate feature
actor only.Expand description
A single-threaded actor with serial access to its state.
Required Associated Types§
Required Methods§
Provided Methods§
Sourceasync fn post_start(
&self,
_myself: &Mailbox<Self>,
_state: &mut Self::State,
) -> Result<(), Self::Error>
async fn post_start( &self, _myself: &Mailbox<Self>, _state: &mut Self::State, ) -> Result<(), Self::Error>
Runs inside the actor task before it receives messages.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".