nash_protocol/protocol/cancel_all_orders/
types.rs1use super::super::{
2 serializable_to_json, try_response_from_json, NashProtocol, ResponseOrError, State,
3};
4use crate::errors::Result;
5use crate::graphql::cancel_all_orders;
6
7use async_trait::async_trait;
8use tokio::sync::RwLock;
9use std::sync::Arc;
10
11#[derive(Clone, Debug)]
14pub struct CancelAllOrders {
15 pub market: String,
16}
17
18#[derive(Clone, Copy, Debug)]
20pub struct CancelAllOrdersResponse {
21 pub accepted: bool,
22}
23
24#[async_trait]
26impl NashProtocol for CancelAllOrders {
27 type Response = CancelAllOrdersResponse;
28
29 async fn graphql(&self, state: Arc<RwLock<State>>) -> Result<serde_json::Value> {
30 let state = state.read().await;
31 let signer = state.signer()?;
32 let query = self.make_query(signer);
33 serializable_to_json(&query)
34 }
35
36 async fn response_from_json(
37 &self,
38 response: serde_json::Value,
39 _state: Arc<RwLock<State>>
40 ) -> Result<ResponseOrError<Self::Response>> {
41 try_response_from_json::<CancelAllOrdersResponse, cancel_all_orders::ResponseData>(response)
42 }
43}