1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use crate::{Client, Result};
use serde::{de::DeserializeOwned, Deserialize};
#[must_use = "Does nothing until you send or execute it"]
pub struct CancelOrderRequest {
client: Client,
txid: String,
}
impl CancelOrderRequest {
pub async fn execute<T: DeserializeOwned>(self) -> Result<T> {
let query = format!("txid={}", self.txid);
self.client
.send_private("/0/private/CancelOrder", Some(query))
.await
}
pub async fn send(self) -> Result<CancelOrderResponse> {
self.execute().await
}
}
#[derive(Debug, Deserialize)]
pub struct CancelOrderResponse {
count: i32,
pending: Option<bool>,
}
impl Client {
pub fn cancel_order(&self, txid: &str) -> CancelOrderRequest {
CancelOrderRequest {
client: self.clone(),
txid: txid.to_string(),
}
}
}