Skip to main content

StateMachineBuilder

Struct StateMachineBuilder 

Source
pub struct StateMachineBuilder<TState: Eq + Hash + Copy, TModel = (), TEvent: Eq + Hash + Copy = ()> { /* private fields */ }

Implementations§

Source§

impl<TState, TModel, TEvent> StateMachineBuilder<TState, TModel, TEvent>
where TState: Eq + Hash + Copy + Sync + Send + 'static, TModel: Sync + Send + 'static, TEvent: Eq + Hash + Copy + Sync + Send + 'static,

Source

pub fn create(initial_state: TState, initial_model: TModel) -> Self

Create a state machine builder that starts in the given state

Source

pub fn in_state(self, state: TState) -> Self

Change the builder context to operate on the given state

Source

pub fn on_enter(self, func: impl Fn() + 'static + Sync + Send) -> Self

Source

pub fn on_enter_mut( self, func: impl Fn(&mut TModel) + 'static + Sync + Send, ) -> Self

Run the given function when the state specified by in_state is entered

Source

pub fn on_leave(self, func: impl Fn() + 'static + Sync + Send) -> Self

Source

pub fn on_leave_mut( self, func: impl Fn(&mut TModel) + 'static + Sync + Send, ) -> Self

Run the given function when the state specified by in_state is left

Source

pub fn on(self, event: TEvent, func: impl Fn() + 'static + Sync + Send) -> Self

Source

pub fn on_mut( self, event: TEvent, func: impl Fn(&mut TModel) + 'static + Sync + Send, ) -> Self

Run the given function when the event is fired in the state specified by in_state

Source

pub fn goto(self, state: TState) -> Self

Transition from the state specified by in_state to the given state when the event specified by on is fired.

Source

pub fn build_passive(self) -> PassiveStateMachine<TState, TModel, TEvent>

Create a passive state machine, finalizing the builder

Source

pub fn build_active( self, tick: impl Fn(&TState, &TModel) -> Option<TState> + Send + Sync + 'static, ) -> ActiveStateMachine<TState, TModel, TEvent>

Create an active state machine, finalizing the builder

Auto Trait Implementations§

§

impl<TState, TModel, TEvent> Freeze for StateMachineBuilder<TState, TModel, TEvent>
where TState: Freeze, TEvent: Freeze, TModel: Freeze,

§

impl<TState, TModel = (), TEvent = ()> !RefUnwindSafe for StateMachineBuilder<TState, TModel, TEvent>

§

impl<TState, TModel, TEvent> Send for StateMachineBuilder<TState, TModel, TEvent>
where TState: Send, TEvent: Send, TModel: Send,

§

impl<TState, TModel, TEvent> Sync for StateMachineBuilder<TState, TModel, TEvent>
where TState: Sync, TEvent: Sync, TModel: Sync,

§

impl<TState, TModel, TEvent> Unpin for StateMachineBuilder<TState, TModel, TEvent>
where TState: Unpin, TEvent: Unpin, TModel: Unpin,

§

impl<TState, TModel, TEvent> UnsafeUnpin for StateMachineBuilder<TState, TModel, TEvent>
where TState: UnsafeUnpin, TEvent: UnsafeUnpin, TModel: UnsafeUnpin,

§

impl<TState, TModel = (), TEvent = ()> !UnwindSafe for StateMachineBuilder<TState, TModel, TEvent>

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.