Struct game_engine_core::StateMachine[][src]

pub struct StateMachine<S> { /* fields omitted */ }
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

impl<S> StateMachine<S>[src]

pub fn is_running(&self) -> bool[src]

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

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

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

pub fn push(
    &mut self,
    state: Box<dyn State<S> + 'static, Global>,
    state_data: &mut S
)
[src]

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

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

Removes all currently running states from the stack.

Trait Implementations

impl<S> Default for StateMachine<S>[src]

pub fn default() -> StateMachine<S>[src]

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

Auto Trait Implementations

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.