//! xtra is a tiny, fast, and safe actor system.
/// This module contains types representing the strength of an address's reference counting, which
/// influences whether the address will keep the actor alive for as long as it lives.
/// This module contains a trait to spawn actors, implemented for all major async runtimes by default.
/// Commonly used types from xtra
pub use ;
pub use ;
pub use ActorManager;
/// A message that can be sent to an [`Actor`](trait.Actor.html) for processing. They are processed
/// one at a time. Only actors implementing the corresponding [`Handler<M>`](trait.Handler.html)
/// trait can be sent a given message.
///
/// # Example
///
/// ```no_run
/// # use xtra::Message;
/// struct MyResult;
/// struct MyMessage;
///
/// impl Message for MyMessage {
/// type Result = MyResult;
/// }
/// ```
/// A trait indicating that an [`Actor`](trait.Actor.html) can handle a given [`Message`](trait.Message.html)
/// asynchronously, and the logic to handle the message.
///
/// This is an [`async_trait`](https://docs.rs/async-trait), so implementations should
/// be annotated `#[async_trait]`.
///
/// # Example
///
/// ```
/// # use xtra::prelude::*;
/// # use xtra::spawn::Smol;
/// # struct MyActor;
/// # impl Actor for MyActor {}
/// struct Msg;
///
/// impl Message for Msg {
/// type Result = u32;
/// }
///
/// #[async_trait::async_trait]
/// impl Handler<Msg> for MyActor {
/// async fn handle(&mut self, message: Msg, ctx: &mut Context<Self>) -> u32 {
/// 20
/// }
/// }
///
/// fn main() {
/// smol::block_on(async {
/// let addr = MyActor.create(None).spawn(&mut Smol::Global);
/// assert_eq!(addr.send(Msg).await, Ok(20));
/// })
/// }
/// ```
/// An actor which can handle [`Message`s](trait.Message.html) one at a time. Actors can only be
/// communicated with by sending [`Message`s](trait.Message.html) through their [`Address`es](address/struct.Address.html).
/// They can modify their private state, respond to messages, and spawn other actors. They can also
/// stop themselves through their [`Context`](struct.Context.html) by calling [`Context::stop`](struct.Context.html#method.stop).
/// This will result in any attempt to send messages to the actor in future failing.
///
/// This is an [`async_trait`](https://docs.rs/async-trait), so implementations should
/// be annotated `#[async_trait]`.
///
/// # Example
///
/// ```rust
/// # use xtra::{KeepRunning, prelude::*};
/// # use xtra::spawn::Smol;
/// # use std::time::Duration;
/// # use smol::Timer;
/// struct MyActor;
///
/// #[async_trait::async_trait]
/// impl Actor for MyActor {
/// async fn started(&mut self, ctx: &mut Context<Self>) {
/// println!("Started!");
/// }
///
/// async fn stopping(&mut self, ctx: &mut Context<Self>) -> KeepRunning {
/// println!("Decided not to keep running");
/// KeepRunning::StopAll
/// }
///
/// async fn stopped(&mut self) {
/// println!("Finally stopping.");
/// }
/// }
///
/// struct Goodbye;
///
/// impl Message for Goodbye {
/// type Result = ();
/// }
///
/// #[async_trait::async_trait]
/// impl Handler<Goodbye> for MyActor {
/// async fn handle(&mut self, _: Goodbye, ctx: &mut Context<Self>) {
/// println!("Goodbye!");
/// ctx.stop();
/// }
/// }
///
/// // Will print "Started!", "Goodbye!", "Decided not to keep running", and then "Finally stopping."
/// smol::block_on(async {
/// let addr = MyActor.create(None).spawn(&mut Smol::Global);
/// addr.send(Goodbye).await;
///
/// Timer::after(Duration::from_secs(1)).await; // Give it time to run
/// })
/// ```
///
/// For longer examples, see the `examples` directory.
/// Whether to keep the actor running after it has been put into a stopping state.
/// True is converted to yes, and false is converted to stop all.