maestro_rust_sdk/utils/
parameters.rs

1pub struct Parameters {
2    params: Vec<String>,
3}
4
5impl Default for Parameters {
6    fn default() -> Self {
7        Self::new()
8    }
9}
10
11impl Parameters {
12    pub fn new() -> Self {
13        Parameters { params: Vec::new() }
14    }
15
16    pub fn format(&self) -> String {
17        if self.params.is_empty() {
18            String::new()
19        } else {
20            format!("?{}", self.params.join("&"))
21        }
22    }
23
24    pub fn count(&mut self, amount: i32) {
25        self.params.push(format!("count={}", amount));
26    }
27
28    pub fn cursor(&mut self, cursor: &str) {
29        self.params.push(format!("cursor={}", cursor));
30    }
31
32    pub fn policy(&mut self, policy: &str) {
33        self.params.push(format!("policy={}", policy));
34    }
35
36    pub fn epoch_no(&mut self, epoch_no: i64) {
37        self.params.push(format!("epoch_no={}", epoch_no));
38    }
39
40    pub fn from(&mut self, from: i64) {
41        self.params.push(format!("from={}", from));
42    }
43
44    pub fn to(&mut self, to: i64) {
45        self.params.push(format!("to={}", to));
46    }
47
48    pub fn set_asc_order(&mut self) {
49        self.params.push("order=asc".to_string());
50    }
51
52    pub fn set_desc_order(&mut self) {
53        self.params.push("order=desc".to_string());
54    }
55
56    pub fn with_cbor(&mut self) {
57        self.params.push("with_cbor=true".to_string());
58    }
59
60    pub fn resolve_datums(&mut self) {
61        self.params.push("resolve_datums=true".to_string());
62    }
63
64    pub fn from_height(&mut self, height: i64) {
65        self.params.push(format!("from_height={}", height));
66    }
67}