Crate zestors

source ·
Expand description

A fast and flexible actor-framework for building fault-tolerant Rust applications.


All items are self-documented, but for a new user it is recommended to go skim through the docs in the following order. Every module gives an overview of what is contained inside, introduces some new concepts and then gives an example on how to use it.

Minimal example

extern crate zestors;
use zestors::{messaging::RecvError, prelude::*};

// Let's define a single request ..
#[derive(Message, Envelope, Debug)]
struct MyRequest {
    param: String,

// .. and create a protocol that accepts this request.
enum MyProtocol {

async fn main() {
    // Now we can spawn a simple actor ..
    let (child, address) = spawn(|mut inbox: Inbox<MyProtocol>| async move {
        loop {
            match inbox.recv().await {
                Ok(msg) => match msg {
                    MyProtocol::MyRequest((request, tx)) => {
                        println!("Received request: {:?}", request.param);
                    MyProtocol::String(string) => {
                        println!("Received message: {:?}", string);
                Err(e) => match e {
                    RecvError::Halted => break "Halted",
                    RecvError::ClosedAndEmpty => break "Closed",

    // .. and send it some messages!

    let response = address
        .request(MyRequest {
            param: "Hi".to_string(),
    assert_eq!(response, 100);

    let response = address
    assert_eq!(response, 100);

    assert_eq!(child.await.unwrap(), "Halted");



Attribute Macros

  • Modifies the enum to implement protocol:

Derive Macros

  • Generates a trait that can be used to send Envelopes of this message.
  • Implements HandleExit for your Handler.
  • Derive the Message trait.