mod deliver;
mod handle;
pub(crate) use deliver::{Delivering, finish, run};
#[doc(inline)]
pub use handle::{ActorExit, ActorHandle, ActorHandleError};
use crate::Mailbox;
pub trait Message: Send + 'static {}
impl<T: Send + 'static> Message for T {}
#[allow(async_fn_in_trait)]
pub trait Actor: Sized + 'static {
type State: 'static;
type Arguments: Send + 'static;
type Error: Send + 'static;
async fn pre_start(
&self,
myself: &Mailbox<Self>,
arguments: Self::Arguments,
) -> Result<Self::State, Self::Error>;
async fn post_start(
&self,
_myself: &Mailbox<Self>,
_state: &mut Self::State,
) -> Result<(), Self::Error> {
Ok(())
}
async fn pre_stop(
&self,
_myself: &Mailbox<Self>,
_state: &mut Self::State,
) -> Result<(), Self::Error> {
Ok(())
}
async fn post_stop(
&self,
_myself: &Mailbox<Self>,
_state: &mut Self::State,
) -> Result<(), Self::Error> {
Ok(())
}
}
#[allow(async_fn_in_trait)]
pub trait Handler<M: Message>: Actor {
async fn handle(
&self,
myself: &Mailbox<Self>,
message: M,
state: &mut Self::State,
) -> Result<(), Self::Error>;
}