pub enum TransitionResult<Machine, DestinationState>{
InvalidTransition,
Ok {
commands: Vec<<Machine as StateMachine>::Command>,
new_state: DestinationState,
},
Err(<Machine as StateMachine>::Error),
}Expand description
A transition result is emitted every time the StateMachine handles an event.
Variants§
InvalidTransition
This state does not define a transition for this event from this state. All other errors should use the Err variant.
Ok
The transition was successful
Err(<Machine as StateMachine>::Error)
There was some error performing the transition
Implementations§
Source§impl<Sm, Ds> TransitionResult<Sm, Ds>
impl<Sm, Ds> TransitionResult<Sm, Ds>
Sourcepub fn ok<CI>(commands: CI, new_state: Ds) -> TransitionResult<Sm, Ds>
pub fn ok<CI>(commands: CI, new_state: Ds) -> TransitionResult<Sm, Ds>
Produce a transition with the provided commands to the provided state. No changes to shared state if it exists
Sourcepub fn from<CurrentState>(
current_state: CurrentState,
) -> TransitionResult<Sm, Ds>where
CurrentState: Into<Ds>,
pub fn from<CurrentState>(
current_state: CurrentState,
) -> TransitionResult<Sm, Ds>where
CurrentState: Into<Ds>,
Uses Into to produce a transition with no commands from the provided current state to
the provided (by type parameter) destination state.
Source§impl<Sm, Ds> TransitionResult<Sm, Ds>
impl<Sm, Ds> TransitionResult<Sm, Ds>
Sourcepub fn commands<CI>(commands: CI) -> TransitionResult<Sm, Ds>
pub fn commands<CI>(commands: CI) -> TransitionResult<Sm, Ds>
Produce a transition with commands relying on Default for the destination state’s value
Source§impl<Sm, Ds> TransitionResult<Sm, Ds>
impl<Sm, Ds> TransitionResult<Sm, Ds>
Sourcepub fn into_general(self) -> TransitionResult<Sm, <Sm as StateMachine>::State>
pub fn into_general(self) -> TransitionResult<Sm, <Sm as StateMachine>::State>
Turns more-specific (struct) transition result into more-general (enum) transition result
Sourcepub fn into_cmd_result(
self,
) -> Result<(Vec<<Sm as StateMachine>::Command>, <Sm as StateMachine>::State), MachineError<<Sm as StateMachine>::Error>>
pub fn into_cmd_result( self, ) -> Result<(Vec<<Sm as StateMachine>::Command>, <Sm as StateMachine>::State), MachineError<<Sm as StateMachine>::Error>>
Transforms the transition result into a machine-ready outcome with commands and new state, or a MachineError