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
pub struct Query {
pub symbol: String,
pub limit: Option<i64>,
}
impl Query {
const QUERY_INITIAL_CAPACITY: usize = 256;
pub fn new(symbol: &str, limit: Option<i64>) -> Self {
Self {
symbol: symbol.to_owned(),
limit,
}
}
}
impl ToString for Query {
fn to_string(&self) -> String {
let mut params = String::with_capacity(Self::QUERY_INITIAL_CAPACITY);
params += &format!("symbol={}", self.symbol.to_owned());
if let Some(limit) = self.limit {
params += &format!("&limit={}", limit.to_string());
}
params
}
}