binance_client/http_api_v3/data/account/get/
request.rs

1//!
2//! The account GET request.
3//!
4
5use chrono::prelude::*;
6
7///
8/// The `https://www.binance.com/api/v3/order` GET request query.
9///
10pub struct Query {
11    /// The allowed time window between the request and response in milliseconds.
12    pub recv_window: Option<i64>,
13    /// The request time in milliseconds.
14    pub timestamp: i64,
15}
16
17impl Default for Query {
18    fn default() -> Self {
19        Self::new()
20    }
21}
22
23impl Query {
24    /// The query params default capacity.
25    const QUERY_INITIAL_CAPACITY: usize = 256;
26
27    ///
28    /// A shortcut constructor.
29    ///
30    pub fn new() -> Self {
31        Self {
32            recv_window: None,
33            timestamp: Utc::now().timestamp_millis(),
34        }
35    }
36}
37
38impl ToString for Query {
39    fn to_string(&self) -> String {
40        let mut params = String::with_capacity(Self::QUERY_INITIAL_CAPACITY);
41        if let Some(recv_window) = self.recv_window {
42            params += &format!("&recvWindow={}", recv_window);
43        }
44        params += &format!("&timestamp={}", self.timestamp);
45        params
46    }
47}