1use xactor::*;
2
3#[message(result = "usize")]
5struct Ping(usize);
6
7struct MyActor {
9 count: usize,
10}
11
12impl Actor for MyActor {}
14
15#[async_trait::async_trait]
17impl Handler<Ping> for MyActor {
18 async fn handle(&mut self, _ctx: &mut Context<Self>, msg: Ping) -> usize {
19 self.count += msg.0;
20 self.count
21 }
22}
23
24#[xactor::main]
25async fn main() -> Result<()> {
26 let addr = MyActor { count: 10 }.start().await?;
28
29 let res = addr.call(Ping(10)).await?;
31 println!("RESULT: {}", res == 20);
32
33 Ok(())
34}