TransitionResult

Enum TransitionResult 

Source
pub enum TransitionResult<Machine, DestinationState>
where Machine: StateMachine, DestinationState: Into<<Machine as StateMachine>::State>,
{ 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

Fields

§commands: Vec<<Machine as StateMachine>::Command>
§new_state: DestinationState
§

Err(<Machine as StateMachine>::Error)

There was some error performing the transition

Implementations§

Source§

impl<Sm, Ds> TransitionResult<Sm, Ds>
where Sm: StateMachine, Ds: Into<<Sm as StateMachine>::State>,

Source

pub fn ok<CI>(commands: CI, new_state: Ds) -> TransitionResult<Sm, Ds>
where CI: IntoIterator<Item = <Sm as StateMachine>::Command>,

Produce a transition with the provided commands to the provided state. No changes to shared state if it exists

Source

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>
where Sm: StateMachine, Ds: Into<<Sm as StateMachine>::State> + Default,

Source

pub fn commands<CI>(commands: CI) -> TransitionResult<Sm, Ds>
where CI: IntoIterator<Item = <Sm as StateMachine>::Command>,

Produce a transition with commands relying on Default for the destination state’s value

Source§

impl<Sm, Ds> TransitionResult<Sm, Ds>
where Sm: StateMachine, Ds: Into<<Sm as StateMachine>::State>,

Source

pub fn into_general(self) -> TransitionResult<Sm, <Sm as StateMachine>::State>

Turns more-specific (struct) transition result into more-general (enum) transition result

Source

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

Trait Implementations§

Source§

impl<Sm, Ds> Default for TransitionResult<Sm, Ds>
where Sm: StateMachine, Ds: Into<<Sm as StateMachine>::State> + Default,

Source§

fn default() -> TransitionResult<Sm, Ds>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<Machine, DestinationState> Freeze for TransitionResult<Machine, DestinationState>
where DestinationState: Freeze, <Machine as StateMachine>::Error: Freeze,

§

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> 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.