23 releases

0.5.2 Jun 13, 2022
0.5.1 Mar 23, 2021
0.5.0-rc.1 Jan 5, 2021
0.5.0-beta.5 Sep 13, 2020
0.2.6 Mar 18, 2020

#271 in Asynchronous

Download history 79/week @ 2023-08-03 95/week @ 2023-08-10 99/week @ 2023-08-17 88/week @ 2023-08-24 56/week @ 2023-08-31 112/week @ 2023-09-07 68/week @ 2023-09-14 70/week @ 2023-09-21 71/week @ 2023-09-28 63/week @ 2023-10-05 81/week @ 2023-10-12 96/week @ 2023-10-19 104/week @ 2023-10-26 146/week @ 2023-11-02 135/week @ 2023-11-09 142/week @ 2023-11-16

539 downloads per month
Used in 4 crates

MPL-2.0 license



A tiny, fast, and safe actor framework. It is modelled around Actix (copyright and license here).

For better ergonomics with xtra, try the spaad crate.


  • Safe: there is no unsafe code in xtra.
  • Tiny: xtra is less than 1k loc.
  • Lightweight: xtra has few dependencies, most of which are lightweight (except futures).
  • Asynchronous and synchronous message handlers.
  • Simple asynchronous message handling interface which allows async/await syntax even when borrowing self.
  • Does not depend on its own runtime and can be run with any futures executor (Tokio, async-std, smol, and wasm-bindgen-futures have the Actor::spawn convenience method implemented out of the box).
  • Quite fast. Running on Tokio, <170ns time from sending a message to it being processed for sending without waiting for a result on my development machine with an AMD Ryzen 3 3200G.
  • However, it is also relatively new and less mature than other options.


use xtra::prelude::*;
use xtra::spawn::Tokio;
use async_trait::async_trait;

struct Printer {
    times: usize,

impl Printer {
    fn new() -> Self {
        Printer { times: 0 }

impl Actor for Printer {}

struct Print(String);
impl Message for Print {
    type Result = ();

impl Handler<Print> for Printer {
    async fn handle(&mut self, print: Print, _ctx: &mut Context<Self>) {
        self.times += 1; // no ActorFuture or anything just to access `self`
        println!("Printing {}. Printed {} times so far.", print.0, self.times);

async fn main() {
    let addr = Printer::new().create(None).spawn(&mut Tokio::Global);
    loop {
            .expect("Printer should not be dropped");

For a longer example, check out Vertex, a chat application written with xtra and spaad on the server.

Too verbose? Check out the spaad sister-crate!

Okay, sounds great! How do I use it?

Check out the docs and the examples to get started! Enabling the with-tokio-1, with-async_std-1, with-smol-1, or with-wasm_bindgen-0_2 features is recommended in order to enable some convenience methods (such as Actor::spawn). Which you enable will depend on which executor you want to use (check out their docs to learn more about each). If you have any questions, feel free to open an issue or message me on the Rust discord.

Latest Breaking Changes

To see the breaking changes for each version, see here. The latest version is 0.5.


~169K SLoC