atomic_actor/
actor.rs

1use crate::{Addr, Context};
2
3/// [`Actor`] reacts to messages. See [`Handler`](crate::Handler) for how to define the reaction.
4pub trait Actor: 'static + Sized + Send {
5    /// The [`Actor`]'s running context. Should be [`Context`]`<Self>`.
6    type Context;
7
8    /// Starts running this [`Actor`] and returns an [`Addr`] to it.
9    ///
10    /// The [`Addr`] can be cloned for sending messages to the [`Actor`] from different threads.
11    fn start(self) -> Addr<Self> {
12        Context::start(self)
13    }
14}