pub trait NashProtocolSubscription: Clone {
type SubscriptionResponse: 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 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 Self: 'async_trait,
'life0: '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 Self: 'async_trait,
'life0: 'async_trait;
// Provided method
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 Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: '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.
Required Associated Types§
type SubscriptionResponse: Send + Sync
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 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
Self: 'async_trait,
'life0: '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
Self: 'async_trait,
'life0: 'async_trait,
Convert JSON response from incoming subscription data into protocol’s associated type
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
Self: 'async_trait,
'life0: 'async_trait,
Provided Methods§
Sourcefn 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
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: '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
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Update state based on data from incoming subscription response
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.