use xtra::prelude::*; struct Initialized(Address); struct Hello; #[derive(xtra::Actor)] struct ActorA { actor_b: Address, } impl Handler for ActorA { type Return = (); async fn handle(&mut self, _: Hello, ctx: &mut Context) { println!("ActorA: Hello"); xtra::join(ctx.mailbox(), self, self.actor_b.send(Hello)) .await .unwrap(); } } #[derive(xtra::Actor)] struct ActorB; impl Handler for ActorB { type Return = (); async fn handle(&mut self, m: Initialized, ctx: &mut Context) { println!("ActorB: Initialized"); let actor_a = m.0; xtra::join(ctx.mailbox(), self, actor_a.send(Hello)) .await .unwrap(); } } impl Handler for ActorB { type Return = (); async fn handle(&mut self, _: Hello, _: &mut Context) { println!("ActorB: Hello"); } } fn main() { smol::block_on(async { let actor_b = xtra::spawn_smol(ActorB, Mailbox::unbounded()); let actor_a = xtra::spawn_smol( ActorA { actor_b: actor_b.clone(), }, Mailbox::unbounded(), ); actor_b.send(Initialized(actor_a.clone())).await.unwrap(); }) }