A tiny, fast, and safe actor framework. It is modelled around Actix (copyright and license here).
futures
, but that's par for the course).futures
by default.async
/await
syntax even when borrowing self
.Actor::spawn
convenience method implemented out of the box).ActorFuture
,
Generic Associated Types (GATs)
must be used. This is an incomplete and unstable feature, which appears to be a way off from stabilisation.
It also uses impl Trait
Type Aliases to avoid Box
ing the futures
returned from the Handler
trait (the library, however, is not totally alloc-free). This means that it requires
nightly to use, and may be unstable in future as those features evolve. What you get in return for this is a cleaner,
simpler, and more expressive API. ```rust
use futures::Future; use xtra::prelude::*;
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 = (); }
// In the real world, the synchronous SyncHandler trait would be better-suited (and is a few ns faster)
impl Handler