StateMachine

Struct StateMachine 

Source
pub struct StateMachine<S, R> { /* private fields */ }

Implementations§

Source§

impl<S, R> StateMachine<S, R>

Source

pub fn new<T: State<State = S, StateResult = R> + 'static>( system_state: S, init_state: T, ) -> Self

creates a state machine with an initial state

Examples found in repository?
examples/basic.rs (line 135)
127fn main() -> BError {
128    let context = BTermBuilder::simple80x50()
129        .with_title("State Machine Sample")
130        .with_dimensions(100, 70)
131        .with_fps_cap(24.0)
132        .build()
133        .expect("failed to build a BTerm");
134
135    let machine = StateMachine::new(Game { num: 0 }, TitleState::default());
136    main_loop(context, machine)
137}

Trait Implementations§

Source§

impl<S: 'static, R: 'static> GameState for StateMachine<S, R>

Source§

fn tick(&mut self, ctx: &mut BTerm)

Auto Trait Implementations§

§

impl<S, R> Freeze for StateMachine<S, R>
where S: Freeze, R: Freeze,

§

impl<S, R> !RefUnwindSafe for StateMachine<S, R>

§

impl<S, R> !Send for StateMachine<S, R>

§

impl<S, R> !Sync for StateMachine<S, R>

§

impl<S, R> Unpin for StateMachine<S, R>
where S: Unpin, R: Unpin,

§

impl<S, R> !UnwindSafe for StateMachine<S, R>

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.