kameo 0.2.0

Simple tokio actors - mpsc channels & no macros
Documentation

Kameo

Simple tokio actors

  • ✅ No Macros
  • ✅ Async Support
  • ✅ Links Between Actors (start_link/start_child)
  • ✅ MPSC Unbounded Channel for Messaging
  • ✅ Concurrent Queries
  • ✅ Panic Safe

Installing

Stable

[dependencies]
kameo = "0.1"

Nightly

kameo = { version = "0.1", features = ["nightly"] }

Defining an Actor

// Define the actor state
struct Counter {
  count: i64,
}

impl Actor for Counter {}

// Define messages
struct Inc(u32);

impl Message<Counter> for Inc {
    type Reply = Result<i64, Infallible>;

    async fn handle(self, state: &mut Counter) -> Self::Reply {
        state.count += self.0 as i64;
        Ok(state.count)
    }
}

Note, with the nightly feature flag enabled, this reply type can be i64 directly without the result.

Starting an Actor & Messaging

let counter_ref: ActorRef<Counter> = Counter { count: 0 }.start();

let count = counter_ref.send(Inc(42)).await?;
println!("Count is {count}");

Contributing

Contributions are welcome! Feel free to submit pull requests, create issues, or suggest improvements.

License

kameo is dual-licensed under either:

at your option.