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

pub trait NashProtocolSubscription: Clone {
    type SubscriptionResponse: 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 subscription_response_from_json<'life0, 'async_trait>(
        &'life0 self,
        response: Value,
        state: Arc<RwLock<State>>
    ) -> Pin<Box<dyn Future<Output = Result<ResponseOrError<Self::SubscriptionResponse>>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
;
fn wrap_response_as_any_subscription<'life0, 'async_trait>(
        &'life0 self,
        response: Value,
        state: Arc<RwLock<State>>
    ) -> Pin<Box<dyn Future<Output = Result<ResponseOrError<SubscriptionResponse>>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
; fn process_subscription_response<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _response: &'life1 Self::SubscriptionResponse,
        _state: Arc<RwLock<State>>
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: Sync + 'async_trait
, { ... } }
Expand description

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

Required methods

Convert the protocol request to GraphQL from communication with Nash server

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

Provided methods

Update state based on data from incoming subscription response

Implementors