Trait State

Source
pub trait State: Clone + PartialEq {
    type Context;
    type Error;

    // Required method
    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 Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided method
    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 Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

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

Required Associated Types§

Source

type Context

Global state shared between all Streamline states.

Source

type Error

The Error shared between all states progressions.

Required Methods§

Source

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 Self: 'async_trait, 'life0: 'async_trait, 'life1: '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

Provided Methods§

Source

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 Self: 'async_trait, 'life0: 'async_trait, 'life1: '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

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§