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 theWorkersum and yielding(total, build_worker)forSupervisor’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
Behaviorimplementation for a normal inherent impl containingreceive(&mut self, from, message)and, optionally,init(&mut self). Omittinginitselects the behavior algebra’s empty initialization transition. The original impl and methods are preserved unchanged.