StateMachine

Struct StateMachine 

Source
pub struct StateMachine<S, Error, Context>
where S: Debug + Default + Hash + Eq + Clone,
{ /* private fields */ }
Expand description

Defines a state machine

Implementations§

Source§

impl<S, Error, Context> StateMachine<S, Error, Context>
where S: Debug + Default + Hash + Eq + Clone,

Source

pub fn new() -> Self

Construct a new StateMachine

Source

pub fn add_action<A>(&mut self, state: S, action: A) -> Result<(), Error>
where A: Action<S, Error, Context> + 'static,

Add an action to the state machine

Source

pub fn remove_action(&mut self, state: S)

Remove an action from the state machine

Source

pub fn force_change_state(&mut self, state: S) -> Result<(), Error>

Force-change the current state to something else

Source

pub fn run(&mut self, context: &Context) -> Result<(), Error>

Run a single iteration of the state machine

Trait Implementations§

Source§

impl<S, Error: Debug, Context: Debug> Debug for StateMachine<S, Error, Context>
where S: Debug + Default + Hash + Eq + Clone + Debug,

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<S, Error, Context> Default for StateMachine<S, Error, Context>
where S: Debug + Default + Hash + Eq + Clone,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<S, Error, Context> Freeze for StateMachine<S, Error, Context>
where S: Freeze,

§

impl<S, Error, Context> !RefUnwindSafe for StateMachine<S, Error, Context>

§

impl<S, Error, Context> !Send for StateMachine<S, Error, Context>

§

impl<S, Error, Context> !Sync for StateMachine<S, Error, Context>

§

impl<S, Error, Context> Unpin for StateMachine<S, Error, Context>
where S: Unpin, Error: Unpin, Context: Unpin,

§

impl<S, Error, Context> !UnwindSafe for StateMachine<S, Error, Context>

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.