StateMachine

Trait StateMachine 

Source
pub trait StateMachine:
    Send
    + Sync
    + Debug
    + 'static {
    // Required method
    fn execute<'life0, 'async_trait>(
        &'life0 mut self,
        _instruction: MachineInstruction,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

A trait defining the capabilities of a state machine within the system.

This trait is designed to be implemented by entities that can execute instructions based on their current state and inputs they receive. The execution of these instructions is asynchronous, allowing for non-blocking operations within the state machine’s logic.

Implementers of this trait must be able to be sent across threads and shared among threads safely, hence the Send, Sync, and 'static bounds. They should also support debugging through the Debug trait.

Required Methods§

Source

fn execute<'life0, 'async_trait>( &'life0 mut self, _instruction: MachineInstruction, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Executes a given instruction asynchronously.

This method takes a mutable reference to self, allowing the state machine to modify its state in response to the instruction. The instruction to be executed is passed as an argument, encapsulating the action to be performed by the state machine.

§Parameters
  • instruction: The instruction that the state machine is to execute.
§Returns

This method does not return a value, but it may result in state changes within the implementing type or the generation of further instructions or events.

Implementors§

Source§

impl<B, E> StateMachine for Engine<B, E>