1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use async_trait;
use crate::;
/// [`Handler`] handles a certain type of message asyncronously.
///
/// # Example
///
/// ```rust
/// use async_trait::async_trait;
/// use atomic_actor::*;
///
/// struct AddOne;
///
/// impl Actor for AddOne {
/// type Context = Context<Self>;
/// }
///
/// #[async_trait]
/// impl Handler<i32> for AddOne {
/// type Result = i32;
///
/// async fn handle(&mut self, message: i32, _: &mut Context<Self>) -> i32 {
/// message + 1
/// }
/// }
///
/// #[tokio::main]
/// async fn main() {
/// let addr = AddOne.start();
/// assert_eq!(addr.send(1).unwrap().await, 2);
/// }