Skip to main content

Actor

Derive Macro Actor 

Source
#[derive(Actor)]
{
    // Attributes available to this derive:
    #[msg]
}
Expand description

#[derive(Actor)] with a #[msg(MyMsg)] attribute.

Generates:

#[async_trait]
impl Actor for Foo {
    type Msg = MyMsg;
    async fn handle(&mut self, ctx: &mut Context<Self>, msg: MyMsg) {
        self.handle_msg(ctx, msg).await;
    }
}

The user only needs to write impl Foo { async fn handle_msg(...) } — no #[async_trait] boilerplate required.