Skip to main content

NashProtocol

Trait NashProtocol 

Source
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§

Source

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

Source

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§

Source

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

Source

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

Source

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

Source

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,

Source

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

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.

Source§

type Response = NashProtocolResponse

Source§

impl NashProtocol for AssetNoncesRequest

Implement protocol bindings for AssetNoncesRequest

Source§

impl NashProtocol for CancelAllOrders

Implement protocol bindings for CancelOrder

Source§

impl NashProtocol for CancelOrderRequest

Implement protocol bindings for CancelOrder

Source§

impl NashProtocol for GetAccountOrderRequest

Implement protocol bindings for GetAccountOrderRequest

Source§

impl NashProtocol for TickerRequest

Implement protocol bindings for TickerRequest

Source§

impl NashProtocol for ListAccountBalancesRequest

Source§

impl NashProtocol for ListAccountOrdersRequest

Source§

impl NashProtocol for ListAccountTradesRequest

Source§

impl NashProtocol for ListCandlesRequest

Source§

impl NashProtocol for ListMarketsRequest

Source§

impl NashProtocol for ListTradesRequest

Source§

impl NashProtocol for OrderbookRequest

Source§

impl NashProtocol for LimitOrderRequest

Source§

impl NashProtocol for MarketOrderRequest

Source§

impl NashProtocol for SignStatesRequest

Implement protocol bindings for SignStatesRequest

Source§

impl NashProtocol for CancelOrdersRequest

Implement protocol bindings for CancelOrders

Source§

impl NashProtocol for LimitOrdersRequest

Source§

impl NashProtocol for MarketOrdersRequest