pub struct StateMachineBuilder<TState: Eq + Hash + Copy, TModel = (), TEvent: Eq + Hash + Copy = ()> { /* private fields */ }Implementations§
Source§impl<TState, TModel, TEvent> StateMachineBuilder<TState, TModel, TEvent>
impl<TState, TModel, TEvent> StateMachineBuilder<TState, TModel, TEvent>
Sourcepub fn create(initial_state: TState, initial_model: TModel) -> Self
pub fn create(initial_state: TState, initial_model: TModel) -> Self
Create a state machine builder that starts in the given state
Sourcepub fn in_state(self, state: TState) -> Self
pub fn in_state(self, state: TState) -> Self
Change the builder context to operate on the given state
pub fn on_enter(self, func: impl Fn() + 'static + Sync + Send) -> Self
Sourcepub fn on_enter_mut(
self,
func: impl Fn(&mut TModel) + 'static + Sync + Send,
) -> Self
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
pub fn on_leave(self, func: impl Fn() + 'static + Sync + Send) -> Self
Sourcepub fn on_leave_mut(
self,
func: impl Fn(&mut TModel) + 'static + Sync + Send,
) -> Self
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
pub fn on(self, event: TEvent, func: impl Fn() + 'static + Sync + Send) -> Self
Sourcepub fn on_mut(
self,
event: TEvent,
func: impl Fn(&mut TModel) + 'static + Sync + Send,
) -> Self
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
Sourcepub fn goto(self, state: TState) -> Self
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.
Sourcepub fn build_passive(self) -> PassiveStateMachine<TState, TModel, TEvent>
pub fn build_passive(self) -> PassiveStateMachine<TState, TModel, TEvent>
Create a passive state machine, finalizing the builder
Sourcepub fn build_active(
self,
tick: impl Fn(&TState, &TModel) -> Option<TState> + Send + Sync + 'static,
) -> ActiveStateMachine<TState, TModel, TEvent>
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>
impl<TState, TModel = (), TEvent = ()> !RefUnwindSafe for StateMachineBuilder<TState, TModel, TEvent>
impl<TState, TModel, TEvent> Send for StateMachineBuilder<TState, TModel, TEvent>
impl<TState, TModel, TEvent> Sync for StateMachineBuilder<TState, TModel, TEvent>
impl<TState, TModel, TEvent> Unpin for StateMachineBuilder<TState, TModel, TEvent>
impl<TState, TModel, TEvent> UnsafeUnpin for StateMachineBuilder<TState, TModel, TEvent>
impl<TState, TModel = (), TEvent = ()> !UnwindSafe for StateMachineBuilder<TState, TModel, TEvent>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more