pub struct AnyModel<Substates: ModelState> { /* private fields */ }Expand description
The following code enables polymorphic handling of different model types and their actions in a state-machine setup. A model is defined in terms of the type of actions it can process, and uses dynamic dispatch to call the correct processing method.
A model implements one of the PureModel, and EffectuflModel traits.
Each trait defines a specific Action associated type, and a corresponding
processing method (process_pure or process_effectful).
Models implementing the PureModel or EffectfulModel traits are wrapped
by the Pure and effectful structs. These are used to implement the
PrivateModel trait that provides into_vtable* methods so models can be
converted into the AnyModel type.
Finally, the AnyModel type is a central struct that can hold any model and
handles actions via its virtual method table. It provides the methods
(process_pure, process_effectful) to process different kinds of actions.