yaaf

Crates.ioyaaf
lib.rsyaaf
version0.2.0
sourcesrc
created_at2020-12-31 01:54:24.376035
updated_at2021-01-01 00:17:59.768833
descriptionYet Another Actor Framework
homepage
repositoryhttps://github.com/mark-burnett/yaaf/
max_upload_size
id329477
size52,540
Mark Burnett (mark-burnett)

documentation

README

Yet Another Actor Framework

A simple, local actor framework.

Example

use ::std::time::Duration;
use ::tokio::time::sleep;
use ::yaaf::prelude::*;

#[derive(Clone, Debug)]
struct MyMessage;

#[derive(Actor)]
#[handle(MyMessage)]
struct MyActor;

#[async_trait]
impl Handler<MyMessage> for MyActor {
    async fn handle(&mut self, _ctx: &mut Context<Self>, _message: MyMessage) {
        println!("Received message");
    }
}

#[tokio::main]
async fn main() -> Result<(), Box<dyn ::std::error::Error>> {
    let mut system = System::new().await?;

    let actor = MyActor;

    let addr = system.add_actor(actor).await?;
    addr.tell(MyMessage);

    sleep(Duration::from_millis(100));

    system.shutdown().await?;
    Ok(())
}

License

This software is licensed under the Apache License, Version 2.0.


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.


Commit count: 34

cargo fmt