Trait nash_protocol::protocol::NashProtocol [−][src]
pub trait NashProtocol: Debug + Send + Sync {
type Response: Debug + Send + Sync;
fn graphql<'life0, 'async_trait>(
&'life0 self,
state: Arc<RwLock<State>>
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn response_from_json<'life0, 'async_trait>(
&'life0 self,
response: Value,
state: Arc<RwLock<State>>
) -> Pin<Box<dyn Future<Output = Result<ResponseOrError<Self::Response>>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: '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
'life0: 'async_trait,
Self: 'async_trait,
{ ... }
fn process_response<'life0, 'life1, 'async_trait>(
&'life0 self,
_response: &'life1 Self::Response,
_state: Arc<RwLock<State>>
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
{ ... }
fn process_error<'life0, 'life1, 'async_trait>(
&'life0 self,
_response: &'life1 ErrorResponse,
_state: Arc<RwLock<State>>
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where
'life0: 'async_trait,
'life1: '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 that all Nash protocol elements implement. Enforces transformation to GraphQL as well as state changes on response processing.
Associated Types
Required methods
Convert the protocol request to GraphQL from communication with Nash server
Convert JSON response to request to the protocol’s associated type
Provided methods
If you want to limit the amount of concurrency of a protocol return a Semaphore here
Any state changes that result from execution of the protocol request The default implementation does nothing to state
Any errors that result from execution of the protocol request The default implementation does nothing to state
Implementors
type Response = DhFillPoolResponse
Implement NashProtocol for the enum, threading through to the base implementation for each of the captured types. This could probably be automated wiht a macro.