class
FSM::Machine(T)
- FSM::Machine(T)
- Reference
- Object
Overview
The immutable, sealed machine definition.
A machine is built once by a machine-scoped builder, then shared across any
number of interpreters and fibers. It resolves transitions and answers state
lookups; it never executes user callbacks. Construction
goes only through .build; the old array-of-states Machine.create form is
gone.
T is the caller's context type. T = Nil is unsupported: a contextless caller
uses FSM::Context. .build rejects Machine(Nil) at
compile time with a diagnostic naming FSM::Context.
Defined in:
fsm/machine.crClass Method Summary
-
.build(id : String, &) : Machine(T)
Build a machine with a machine-scoped builder.
Instance Method Summary
- #id : String
-
#states : Hash(String, StateDefinition(T))
A shallow copy of the states, so callers cannot add, delete, or replace entries in the machine's internal definition.
Class Method Detail
Build a machine with a machine-scoped builder. The yielded builder registers states; at the end of the block it validates every transition target and seals every definition, then returns the immutable machine.
Instance Method Detail
A shallow copy of the states, so callers cannot add, delete, or replace entries in the machine's internal definition. The StateDefinition values are shared but sealed, so the definition stays immutable. Internal code reads @states directly.