StateMachine

Struct StateMachine 

Source
pub struct StateMachine<S> { /* private fields */ }
Expand description

A state machine that holds the stack of states and performs transitions between states. It can be created using

StateMachine::<()>::default()

§Generics

  • S: State data, the data that is sent to states for them to do their operations.

Implementations§

Source§

impl<S> StateMachine<S>

Source

pub fn is_running(&self) -> bool

Returns if the state machine still has states in its stack.

Source

pub fn update(&mut self, state_data: &mut S)

Updates the state at the top of the stack with the provided data. If the states returns a transition, perform it.

Source

pub fn push(&mut self, state: Box<dyn State<S>>, state_data: &mut S)

Push a state on the stack and start it. Pauses any previously active state.

Source

pub fn stop(&mut self, state_data: &mut S)

Removes all currently running states from the stack.

Trait Implementations§

Source§

impl<S> Default for StateMachine<S>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<S> Freeze for StateMachine<S>

§

impl<S> !RefUnwindSafe for StateMachine<S>

§

impl<S> !Send for StateMachine<S>

§

impl<S> !Sync for StateMachine<S>

§

impl<S> Unpin for StateMachine<S>

§

impl<S> !UnwindSafe for StateMachine<S>

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.