Xtor: An handler async actor framework.

CI Crates

Key features

usage

add xtor to your library

cargo add xtor

write some code

```rs use anyhow::Result; use asynctrait::asynctrait; use xtor::actor::{context::Context, message::Handler, runner::Actor};

// first define actor struct HelloActor; impl Actor for HelloActor {}

// then define message

[xtor::message(result = "()")]

[derive(Debug)]

struct Hello;

// then impl the handler

[async_trait]

impl Handler for HelloActor { async fn handle(&self, _ctx: &Context, msg: Hello) -> Result<()> { println!("{:?} received", &msg); Ok(()) } }

// main will finish when all actors died out.

[xtor::main]

async fn main() -> Result<()> { let helloactor = HelloActor; let helloactoraddress = helloactor.spawn().await?; helloactoraddress.call::(Hello).await } ```

project structure

References