Skip to main content

Crate behavior_macros

Crate behavior_macros 

Source
Expand description

behavior-macros — proc-macros for the behavior algebra.

workers! compiles a mixed fleet declaration into the erasure-free sum a Supervisor fleet requires (design: actorpass docs, surface talk #2): (count, Type, build_fn) per worker kind → a Worker enum with a delegated Behavior impl, a per-variant range build_worker, and the total count. Worker is a type—every worker stays its own actor.

v1 scope: every worker kind shares the SAME protocol (Event, Sends, Error, and Birth — taken from the first kind). Mixed protocols need the hand-written sum (the WorkerMsg widening is a deliberate, documented step — not this macro’s job yet).

Macros§

workers
workers![(4, WorkerA, build_a), (2, WorkerB, build_b)] → a block declaring the Worker sum and yielding (total, build_worker) for Supervisor’s fleet. Slots are contiguous per variant (slot = nonce; rest-for-one’s birth order is the declaration order).

Attribute Macros§

behavior
Generate the mechanical Behavior implementation for a normal inherent impl containing receive(&mut self, from, message) and, optionally, init(&mut self). Omitting init selects the behavior algebra’s empty initialization transition. The original impl and methods are preserved unchanged.