Trait nash_protocol::protocol::NashProtocolPipeline[][src]

pub trait NashProtocolPipeline: Debug + Send + Sync {
    type PipelineState: Send + Sync;
    type ActionType: NashProtocol;
    fn init_state<'life0, 'async_trait>(
        &'life0 self,
        state: Arc<RwLock<State>>
    ) -> Pin<Box<dyn Future<Output = Self::PipelineState> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
;
fn next_step<'life0, 'life1, 'async_trait>(
        &'life0 self,
        pipeline_state: &'life1 Self::PipelineState,
        client_state: Arc<RwLock<State>>
    ) -> Pin<Box<dyn Future<Output = Result<Option<Self::ActionType>>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
;
fn process_step<'life0, 'life1, 'async_trait>(
        &'life0 self,
        result: <<Self as NashProtocolPipeline>::ActionType as NashProtocol>::Response,
        pipeline_state: &'life1 mut Self::PipelineState
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
;
fn output(
        &self,
        pipeline_state: Self::PipelineState
    ) -> Result<ResponseOrError<<Self::ActionType as NashProtocol>::Response>>; fn acquire_permit<'life0, 'async_trait>(
        &'life0 self,
        _state: Arc<RwLock<State>>
    ) -> Pin<Box<dyn Future<Output = Option<OwnedSemaphorePermit>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
, { ... }
fn run_before<'life0, 'async_trait>(
        &'life0 self,
        _state: Arc<RwLock<State>>
    ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<ProtocolHook>>>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
, { ... }
fn run_after<'life0, 'async_trait>(
        &'life0 self,
        _state: Arc<RwLock<State>>
    ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<ProtocolHook>>>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
, { ... } }
Expand description

Trait to abstract over a series of linked protocol requests. For example we use this to abstract over repeated calls to sign_state until there are no more states to sign.

Associated Types

State managed by pipeline and used to hold intermediate results and allow the implementer to decide whether the pipeline is over

Wrapper type for all actions this pipeline can take

Required methods

Create initial state for the pipeline

Give next action to take or return None if pipeline is finished. &State needs to be mutable as client may modify itself when producing the next step (e.g., removing and r value generate a signature)

Process the results of a pipeline step

Get results from pipeline or None if the pipeline is not finished

Provided methods

If you want to limit the amount of concurrency of a pipeline return a Semaphore here

Implementors

Implement NashProtocolPipeline for ProtocolHook so that hooks can be run as typical pipelines

A pipeline is a superset of NashProtocol, so something of type NashProtocol can by itself be considered a valid pipeline. This is convenient if we just want to have a single client interface that can take pipelines or protocol requests. We can do this once generically and it will apply to all implementations