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

1//!
2//! The depth GET request.
3//!
4
5///
6/// The `https://www.binance.com/api/v3/depth` GET request query.
7///
8pub struct Query {
9    /// The symbol name.
10    pub symbol: String,
11    /// The maximum number of depth elements to return.
12    pub limit: Option<i64>,
13}
14
15impl Query {
16    /// The query params default capacity.
17    const QUERY_INITIAL_CAPACITY: usize = 256;
18
19    ///
20    /// A shortcut constructor.
21    ///
22    pub fn new(symbol: &str, limit: Option<i64>) -> Self {
23        Self {
24            symbol: symbol.to_owned(),
25            limit,
26        }
27    }
28}
29
30impl ToString for Query {
31    fn to_string(&self) -> String {
32        let mut params = String::with_capacity(Self::QUERY_INITIAL_CAPACITY);
33        params += &format!("symbol={}", self.symbol.to_owned());
34        if let Some(limit) = self.limit {
35            params += &format!("&limit={}", limit);
36        }
37        params
38    }
39}