Skip to main content

SResult

Type Alias SResult 

Source
pub type SResult<Storage, T, OkState, ErrState>
where Storage: StateStorage, T: StateMachineImpl,
= Result<State<Storage, T, OkState>, State<Storage, T, ErrState>>;
Expand description

A result whose success and error values are states of the same machine.

This is useful for fallible state-machine methods where both branches return ownership of the same runtime value in different states:

fn authenticate_if<S>(
    self: State<S, Connection, Connected>,
    user: Option<String>,
) -> SResult<S, Connection, Authenticated, Connected>
where
    S: SMut,
{
    match user {
        Some(user) => Ok(magicstatemachines::transition!(self, user)),
        None => Err(self),
    }
}

Aliased Type§

pub enum SResult<Storage, T, OkState, ErrState>
where Storage: StateStorage, T: StateMachineImpl,
{ Ok(State<Storage, T, OkState>), Err(State<Storage, T, ErrState>), }

Variants§

§1.0.0

Ok(State<Storage, T, OkState>)

Contains the success value

§1.0.0

Err(State<Storage, T, ErrState>)

Contains the error value