Expand description

This crate aims to provide a minimalist and high-performance actor framework for Rust with significantly less complexity than other frameworks like Actix.

In this framework, each Actor is its own OS-level thread. This makes debugging noticeably simpler, and is suitably performant when the number of actors is less than or equal to the number of CPU threads.


use tonari_actor::{Actor, Context, System};

struct TestActor {}
impl Actor for TestActor {
    type Context = Context<Self::Message>;
    type Error = ();
    type Message = usize;

    fn name() -> &'static str {

    fn handle(&mut self, _context: &mut Self::Context, message: Self::Message) -> Result<(), ()> {
        println!("message: {}", message);


let mut system = System::new("default");

// will spin up a new thread running this actor
let addr = system.spawn(TestActor {}).unwrap();

// send messages to actors to spin off work...

// ask the actors to finish and join the threads.


Tools to make a given actor able to receive delayed and recurring messages.


Capacity of actor’s normal- and high-priority inboxes. For each inbox type, None signifies default capacity. Converts from usize.

An execution context for a specific actor. Specifically, this is useful for managing the lifecycle of itself (through the myself field) and other actors via the SystemHandle provided. A time-based deadline for receiving a message can be set using Self::set_deadline() and friends.

The actor message channel is disconnected.

Similar to Addr, but rather than pointing to a specific actor, it is typed for any actor that handles a given message-response type.

Failures that can occur when sending a message to an actor.

A builder for specifying how to spawn an Actor. You can specify your own Addr for the Actor, the capacity of the Actor’s inbox, and you can specify whether to spawn the Actor into its own thread or block on the current calling thread.

Systems are responsible for keeping track of their spawned actors, and managing their lifecycles appropriately.

Contains the “metadata” of the system, including information about the registry of actors currently existing within the system.


The set of available control messages that all actors respond to.

Urgency of a given message. All high-priority messages are delivered before normal priority.

Reasons why sending a message to an actor can fail.


The base actor trait.