Struct StateMachine

Source
pub struct StateMachine<TCriteria, TAction> { /* private fields */ }
Expand description

A compiled state machine.

The StateMachine can be created with the Builder.

Implementations§

Source§

impl<TCriteria, TAction> StateMachine<TCriteria, TAction>
where TCriteria: Criteria,

Source

pub fn start(&self) -> MachineState

Acquires the initial state of the state machine.

Source

pub fn step( &self, current: MachineState, input: &TCriteria::Input, ) -> MachineState

Performs a step from the current machine state with the given input.

Source§

impl<TCriteria, TAction> StateMachine<TCriteria, TAction>
where TAction: Action,

Source

pub fn execute(&self, current: MachineState, input: &mut TAction::Input)

Executes the actions of the current state with the given input.

Use Self::execute_mut if the current TAction is an ActionMut.

Source§

impl<TCriteria, TAction> StateMachine<TCriteria, TAction>
where TAction: ActionMut,

Source

pub fn execute_mut(&mut self, current: MachineState, input: &mut TAction::Input)

Executes the actions of the current state with the given input.

Use Self::execute if the current TAction is an Action.

Source§

impl<TCriteria, TAction> StateMachine<TCriteria, TAction>
where TAction: Action, TCriteria: Criteria<Input = TAction::Input>,

Source

pub fn step_and_execute( &self, current: MachineState, input: &mut TAction::Input, ) -> MachineState

Performs a step from the current state and executes any actions based on the new state.

This method is available only if the TCriteria and TAction have the same Input type and is equivalent to:

let next_state = machine.step(current_state, &input);
machine.execute(current_state, &mut input);
Source§

impl<TCriteria, TAction> StateMachine<TCriteria, TAction>
where TAction: ActionMut, TCriteria: Criteria<Input = TAction::Input>,

Source

pub fn step_and_execute_mut( &mut self, current: MachineState, input: &mut TAction::Input, ) -> MachineState

Performs a step from the current state and executes any actions based on the new state.

This method is available only if the TCriteria and TAction have the same Input type and is equivalent to:

let next_state = machine.step(current_state, &input);
machine.execute_mut(current_state, &mut input);

Trait Implementations§

Source§

impl<TCriteria: Debug, TAction: Debug> Debug for StateMachine<TCriteria, TAction>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<TCriteria, TAction> Freeze for StateMachine<TCriteria, TAction>

§

impl<TCriteria, TAction> RefUnwindSafe for StateMachine<TCriteria, TAction>
where TAction: RefUnwindSafe, TCriteria: RefUnwindSafe,

§

impl<TCriteria, TAction> Send for StateMachine<TCriteria, TAction>
where TAction: Send, TCriteria: Send,

§

impl<TCriteria, TAction> Sync for StateMachine<TCriteria, TAction>
where TAction: Sync, TCriteria: Sync,

§

impl<TCriteria, TAction> Unpin for StateMachine<TCriteria, TAction>
where TAction: Unpin, TCriteria: Unpin,

§

impl<TCriteria, TAction> UnwindSafe for StateMachine<TCriteria, TAction>
where TAction: UnwindSafe, TCriteria: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.