meio
Lightweight async actor framework for Rust.
- Zero-cost
- Full control
- Tiny API
This framework designed for professional use, because for
huge apps you need a full control of every aspect of the app
and you haven't be bounded by sepcific restrictions.
Usage
wrapper!(MyActorClient for MyActor);
impl MyActorClient {
pub async fn do_it(&mut self) -> Result<u8, Error> {
self.interact(DoIt).await
}
}
struct MyActor { }
struct DoIt;
impl Interaction for DoIt {
type Output = u8;
}
#[async_trait]
impl Actor for MyActor {
type Interface = MyActorClient;
}
#[async_trait]
impl Handler<DoIt> for MyActor {
async fn handle(&mut self, msg: DoIt) -> Result<u8, Error> {
1
}
}
#[tokio::main]
async fn main() -> Result<(), Error> {
let actor = MyActor { };
let addr = meio::spawn(actor);
addr.do_it().await?;
addr.terminate().await?;
Ok(())
}