pub trait NashProtocolPipeline:
Debug
+ Send
+ Sync {
type PipelineState: Send + Sync;
type ActionType: NashProtocol;
// Required methods
fn init_state<'life0, 'async_trait>(
&'life0 self,
state: Arc<RwLock<State>>,
) -> Pin<Box<dyn Future<Output = Self::PipelineState> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: '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 Self: 'async_trait,
'life0: 'async_trait,
'life1: '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 Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn output(
&self,
pipeline_state: Self::PipelineState,
) -> Result<ResponseOrError<<Self::ActionType as NashProtocol>::Response>>;
// Provided methods
fn acquire_permit<'life0, 'async_trait>(
&'life0 self,
_state: Arc<RwLock<State>>,
) -> Pin<Box<dyn Future<Output = Option<OwnedSemaphorePermit>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: '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 Self: 'async_trait,
'life0: '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 Self: 'async_trait,
'life0: '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.
Required Associated Types§
Sourcetype PipelineState: Send + Sync
type PipelineState: Send + Sync
State managed by pipeline and used to hold intermediate results and allow the implementer to decide whether the pipeline is over
Sourcetype ActionType: NashProtocol
type ActionType: NashProtocol
Wrapper type for all actions this pipeline can take
Required Methods§
Sourcefn init_state<'life0, 'async_trait>(
&'life0 self,
state: Arc<RwLock<State>>,
) -> Pin<Box<dyn Future<Output = Self::PipelineState> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn init_state<'life0, 'async_trait>(
&'life0 self,
state: Arc<RwLock<State>>,
) -> Pin<Box<dyn Future<Output = Self::PipelineState> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Create initial state for the pipeline
Sourcefn 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
Self: 'async_trait,
'life0: 'async_trait,
'life1: '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
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
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)
Sourcefn 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
Self: 'async_trait,
'life0: 'async_trait,
'life1: '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
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Process the results of a pipeline step
Sourcefn output(
&self,
pipeline_state: Self::PipelineState,
) -> Result<ResponseOrError<<Self::ActionType as NashProtocol>::Response>>
fn output( &self, pipeline_state: Self::PipelineState, ) -> Result<ResponseOrError<<Self::ActionType as NashProtocol>::Response>>
Get results from pipeline or None if the pipeline is not finished
Provided Methods§
Sourcefn acquire_permit<'life0, 'async_trait>(
&'life0 self,
_state: Arc<RwLock<State>>,
) -> Pin<Box<dyn Future<Output = Option<OwnedSemaphorePermit>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn acquire_permit<'life0, 'async_trait>(
&'life0 self,
_state: Arc<RwLock<State>>,
) -> Pin<Box<dyn Future<Output = Option<OwnedSemaphorePermit>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
If you want to limit the amount of concurrency of a pipeline return a Semaphore here
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
Self: 'async_trait,
'life0: '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
Self: 'async_trait,
'life0: 'async_trait,
Implementors§
Source§impl NashProtocolPipeline for ProtocolHook
Implement NashProtocolPipeline for ProtocolHook so that hooks can be run as typical pipelines
impl NashProtocolPipeline for ProtocolHook
Implement NashProtocolPipeline for ProtocolHook so that hooks can be run as typical pipelines
type PipelineState = ProtocolHookState
type ActionType = NashProtocolRequest
Source§impl NashProtocolPipeline for SignAllStates
impl NashProtocolPipeline for SignAllStates
Source§impl<T> NashProtocolPipeline for T
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
impl<T> NashProtocolPipeline for T
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