[][src]Trait nash_protocol::protocol::NashProtocolSubscription

pub trait NashProtocolSubscription: Clone {
    type SubscriptionResponse: Send + Sync;
#[must_use]    pub fn graphql<'life0, 'async_trait>(
        &'life0 self,
        state: Arc<Mutex<State>>
    ) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
;
#[must_use] pub fn subscription_response_from_json<'life0, 'async_trait>(
        &'life0 self,
        response: Value,
        state: Arc<Mutex<State>>
    ) -> Pin<Box<dyn Future<Output = Result<ResponseOrError<Self::SubscriptionResponse>>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
;
#[must_use] pub fn wrap_response_as_any_subscription<'life0, 'async_trait>(
        &'life0 self,
        response: Value,
        state: Arc<Mutex<State>>
    ) -> Pin<Box<dyn Future<Output = Result<ResponseOrError<SubscriptionResponse>>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
; #[must_use] pub fn process_subscription_response<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _response: &'life1 Self::SubscriptionResponse,
        _state: Arc<Mutex<State>>
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: Sync + 'async_trait
, { ... } }

Trait that defines subscriptions over the Nash protocol. The main difference is that the transformation of response data to SubscriptionResponse must occur on every incoming subscription event. Similarly, the subscription is able to modify client state on every incoming event. This last property is important for a subscription that updates asset nonces once that is available on the backend.

Associated Types

Loading content...

Required methods

#[must_use]pub fn graphql<'life0, 'async_trait>(
    &'life0 self,
    state: Arc<Mutex<State>>
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

Convert the protocol request to GraphQL from communication with Nash server

#[must_use]pub fn subscription_response_from_json<'life0, 'async_trait>(
    &'life0 self,
    response: Value,
    state: Arc<Mutex<State>>
) -> Pin<Box<dyn Future<Output = Result<ResponseOrError<Self::SubscriptionResponse>>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

Convert JSON response from incoming subscription data into protocol's associated type

#[must_use]pub fn wrap_response_as_any_subscription<'life0, 'async_trait>(
    &'life0 self,
    response: Value,
    state: Arc<Mutex<State>>
) -> Pin<Box<dyn Future<Output = Result<ResponseOrError<SubscriptionResponse>>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

Loading content...

Provided methods

#[must_use]pub fn process_subscription_response<'life0, 'life1, 'async_trait>(
    &'life0 self,
    _response: &'life1 Self::SubscriptionResponse,
    _state: Arc<Mutex<State>>
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: Sync + 'async_trait, 
[src]

Update state based on data from incoming subscription response

Loading content...

Implementors

impl NashProtocolSubscription for SubscriptionRequest[src]

type SubscriptionResponse = SubscriptionResponse

impl NashProtocolSubscription for SubscribeTrades[src]

type SubscriptionResponse = TradesResponse

impl NashProtocolSubscription for SubscribeOrderbook[src]

type SubscriptionResponse = SubscribeOrderbookResponse

Loading content...