CreateStateMachine

Trait CreateStateMachine 

Source
pub trait CreateStateMachine {
    // Required method
    fn create_state_machine(self) -> Box<dyn StateMachine>;
}
Expand description

A trait for creating a state machine.

This trait is intended to be implemented by types that can be converted into a state machine. A state machine, in this context, is an entity capable of executing a set of instructions or operations based on its current state and inputs it receives.

Implementers of this trait should provide the logic to initialize and return a new instance of a state machine, encapsulated within a Box<dyn StateMachine>. This allows for dynamic dispatch to the state machine’s methods, enabling polymorphism where different types of state machines can be used interchangeably at runtime.

§Returns

  • Box<dyn StateMachine>: A boxed state machine object that can be dynamically dispatched.

Required Methods§

Source

fn create_state_machine(self) -> Box<dyn StateMachine>

Creates and returns a new state machine instance.

This method consumes the implementer and returns a new instance of a state machine encapsulated within a Box<dyn StateMachine>. The specific type of the state machine returned can vary, allowing for flexibility and reuse of the state machine logic across different contexts.

Implementors§