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 Crew enum with a delegated Behavior impl, a per-variant range crew_build, and the total count. Crew 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 CrewMsg 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 Crew sum and yielding (total, crew_build) for Supervisor’s fleet. Slots are contiguous per variant (slot = nonce; rest-for-one’s birth order is the declaration order).