use xactor::*;
#[message(result = "usize")]
struct Ping(usize);
struct MyActor {
count: usize,
}
impl Actor for MyActor {}
#[async_trait::async_trait]
impl Handler<Ping> for MyActor {
async fn handle(&mut self, _ctx: &mut Context<Self>, msg: Ping) -> usize {
self.count += msg.0;
self.count
}
}
#[xactor::main]
async fn main() -> Result<()> {
let addr = MyActor { count: 10 }.start().await?;
let res = addr.call(Ping(10)).await?;
println!("RESULT: {}", res == 20);
Ok(())
}