[][src]Trait streamline::State

pub trait State: Clone + PartialEq {
    type Context;
    type Error;
#[must_use]    fn next<'life0, 'life1, 'async_trait>(
        &'life0 self,
        context: Option<&'life1 mut Self::Context>
    ) -> Pin<Box<dyn Future<Output = Result<Option<Self>, Self::Error>> + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
; #[must_use] fn revert<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _context: Option<&'life1 mut Self::Context>
    ) -> Pin<Box<dyn Future<Output = Result<Option<Self>, Self::Error>> + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
, { ... } }

The State trait defines the way that a Streamline progresses to (or from) the next state.

Associated Types

type Context

Global state shared between all Streamline states.

type Error

The Error shared between all states progressions.

Loading content...

Required methods

#[must_use]fn next<'life0, 'life1, 'async_trait>(
    &'life0 self,
    context: Option<&'life1 mut Self::Context>
) -> Pin<Box<dyn Future<Output = Result<Option<Self>, Self::Error>> + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 

Derives the next state when progressing through a Streamline that has not encountered any errors. There are no limits to how many times a state can be visited, but all mappings between user states must be explicit. If Err(Self::Error) is returned from this method, the reversion process is triggered. If Ok(None) is returned, the Streamline ends. If Ok(Some(Self)) is returned, the stream continues to the next iteration of next

Loading content...

Provided methods

#[must_use]fn revert<'life0, 'life1, 'async_trait>(
    &'life0 self,
    _context: Option<&'life1 mut Self::Context>
) -> Pin<Box<dyn Future<Output = Result<Option<Self>, Self::Error>> + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 

Handles the mapping between a state and its previous state in the case of reversion on Err from next(). By default, revert simply ends the Streamline

Loading content...

Implementors

Loading content...