Skip to main content

Receive

Derive Macro Receive 

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

#[derive(Receive)] with a #[msg(MyMsg)] attribute on the actor struct, plus a separate enum MyMsg { Inc, Get(...), … } whose variants must be visible at the macro expansion site.

Generates an impl atomr_core::actor::Actor whose handle method dispatches each enum variant to a method on the actor named on_<snake_variant>. Unit variants get (&mut self, ctx); tuple variants get (&mut self, ctx, field0, field1, …). Struct variants are not supported (produces a compile error).

This is the typed message-router DSL referenced by docs/idiomatic-rust.md (P-8 follow-on) and Phase 1.E.