pub trait NashProtocol:
Debug
+ Send
+ Sync {
type Response: Debug + Send + Sync;
// Required methods
fn graphql<'life0, 'async_trait>(
&'life0 self,
state: Arc<RwLock<State>>,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: '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 Self: 'async_trait,
'life0: 'async_trait;
// 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 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 Self: 'async_trait,
'life0: 'async_trait,
'life1: '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 Self: 'async_trait,
'life0: 'async_trait,
'life1: '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 that all Nash protocol elements implement. Enforces transformation to GraphQL as well as state changes on response processing.
Required Associated Types§
Required Methods§
Sourcefn graphql<'life0, 'async_trait>(
&'life0 self,
state: Arc<RwLock<State>>,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn graphql<'life0, 'async_trait>(
&'life0 self,
state: Arc<RwLock<State>>,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Convert the protocol request to GraphQL from communication with Nash server
Sourcefn 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
Self: 'async_trait,
'life0: '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
Self: 'async_trait,
'life0: 'async_trait,
Convert JSON response to request to the protocol’s associated type
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 protocol return a Semaphore here
Sourcefn 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
Self: 'async_trait,
'life0: 'async_trait,
'life1: '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
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Any state changes that result from execution of the protocol request The default implementation does nothing to state
Sourcefn 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
Self: 'async_trait,
'life0: 'async_trait,
'life1: '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
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Any errors that result from execution of the protocol request The default implementation does nothing to state
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 NashProtocol for DhFillPoolRequest
impl NashProtocol for DhFillPoolRequest
Source§impl NashProtocol for NashProtocolRequest
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.
impl NashProtocol for NashProtocolRequest
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.
Source§impl NashProtocol for AssetNoncesRequest
Implement protocol bindings for AssetNoncesRequest
impl NashProtocol for AssetNoncesRequest
Implement protocol bindings for AssetNoncesRequest
Source§impl NashProtocol for CancelAllOrders
Implement protocol bindings for CancelOrder
impl NashProtocol for CancelAllOrders
Implement protocol bindings for CancelOrder
Source§impl NashProtocol for CancelOrderRequest
Implement protocol bindings for CancelOrder
impl NashProtocol for CancelOrderRequest
Implement protocol bindings for CancelOrder
Source§impl NashProtocol for GetAccountOrderRequest
Implement protocol bindings for GetAccountOrderRequest
impl NashProtocol for GetAccountOrderRequest
Implement protocol bindings for GetAccountOrderRequest
Source§impl NashProtocol for TickerRequest
Implement protocol bindings for TickerRequest
impl NashProtocol for TickerRequest
Implement protocol bindings for TickerRequest
type Response = TickerResponse
Source§impl NashProtocol for ListCandlesRequest
impl NashProtocol for ListCandlesRequest
Source§impl NashProtocol for ListMarketsRequest
impl NashProtocol for ListMarketsRequest
Source§impl NashProtocol for ListTradesRequest
impl NashProtocol for ListTradesRequest
Source§impl NashProtocol for OrderbookRequest
impl NashProtocol for OrderbookRequest
type Response = OrderbookResponse
Source§impl NashProtocol for LimitOrderRequest
impl NashProtocol for LimitOrderRequest
Source§impl NashProtocol for MarketOrderRequest
impl NashProtocol for MarketOrderRequest
Source§impl NashProtocol for SignStatesRequest
Implement protocol bindings for SignStatesRequest
impl NashProtocol for SignStatesRequest
Implement protocol bindings for SignStatesRequest
Source§impl NashProtocol for CancelOrdersRequest
Implement protocol bindings for CancelOrders
impl NashProtocol for CancelOrdersRequest
Implement protocol bindings for CancelOrders