pub enum TransitionResult<Machine, DestinationState>{
InvalidTransition,
Ok {
commands: Vec<Machine::Command>,
new_state: DestinationState,
},
Err(Machine::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::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) -> Selfwhere
CI: IntoIterator<Item = Sm::Command>,
pub fn ok<CI>(commands: CI, new_state: Ds) -> Selfwhere
CI: IntoIterator<Item = Sm::Command>,
Produce a transition with the provided commands to the provided state. No changes to shared state if it exists
Source§impl<Sm, Ds> TransitionResult<Sm, Ds>
impl<Sm, Ds> TransitionResult<Sm, Ds>
Sourcepub fn commands<CI>(commands: CI) -> Selfwhere
CI: IntoIterator<Item = Sm::Command>,
pub fn commands<CI>(commands: CI) -> Selfwhere
CI: IntoIterator<Item = Sm::Command>,
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::State>
pub fn into_general(self) -> TransitionResult<Sm, Sm::State>
Turns more-specific (struct) transition result into more-general (enum) transition result
Sourcepub fn into_cmd_result(
self,
) -> Result<(Vec<Sm::Command>, Sm::State), MachineError<Sm::Error>>
pub fn into_cmd_result( self, ) -> Result<(Vec<Sm::Command>, Sm::State), MachineError<Sm::Error>>
Transforms the transition result into a machine-ready outcome with commands and new state, or a MachineError
Trait Implementations§
Auto Trait Implementations§
impl<Machine, DestinationState> Freeze for TransitionResult<Machine, DestinationState>
impl<Machine, DestinationState> RefUnwindSafe for TransitionResult<Machine, DestinationState>where
DestinationState: RefUnwindSafe,
<Machine as StateMachine>::Error: RefUnwindSafe,
<Machine as StateMachine>::Command: RefUnwindSafe,
impl<Machine, DestinationState> Send for TransitionResult<Machine, DestinationState>where
DestinationState: Send,
<Machine as StateMachine>::Error: Send,
<Machine as StateMachine>::Command: Send,
impl<Machine, DestinationState> Sync for TransitionResult<Machine, DestinationState>where
DestinationState: Sync,
<Machine as StateMachine>::Error: Sync,
<Machine as StateMachine>::Command: Sync,
impl<Machine, DestinationState> Unpin for TransitionResult<Machine, DestinationState>where
DestinationState: Unpin,
<Machine as StateMachine>::Error: Unpin,
<Machine as StateMachine>::Command: Unpin,
impl<Machine, DestinationState> UnwindSafe for TransitionResult<Machine, DestinationState>where
DestinationState: UnwindSafe,
<Machine as StateMachine>::Error: UnwindSafe,
<Machine as StateMachine>::Command: UnwindSafe,
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