Skip to main content

ic_query/nns/data_center/report/model/
request.rs

1use std::path::PathBuf;
2
3///
4/// NnsDataCenterCacheRequest
5///
6#[derive(Clone, Debug, Eq, PartialEq)]
7pub struct NnsDataCenterCacheRequest {
8    pub icp_root: PathBuf,
9    pub network: String,
10}
11
12impl NnsDataCenterCacheRequest {
13    #[must_use]
14    pub fn new(icp_root: impl Into<PathBuf>, network: impl Into<String>) -> Self {
15        Self {
16            icp_root: icp_root.into(),
17            network: network.into(),
18        }
19    }
20}
21
22///
23/// NnsDataCenterListRequest
24///
25#[derive(Clone, Debug, Eq, PartialEq)]
26pub struct NnsDataCenterListRequest {
27    pub cache: NnsDataCenterCacheRequest,
28    pub source_endpoint: String,
29    pub now_unix_secs: u64,
30}
31
32impl NnsDataCenterListRequest {
33    #[must_use]
34    pub fn new(
35        cache: NnsDataCenterCacheRequest,
36        source_endpoint: impl Into<String>,
37        now_unix_secs: u64,
38    ) -> Self {
39        Self {
40            cache,
41            source_endpoint: source_endpoint.into(),
42            now_unix_secs,
43        }
44    }
45}
46
47///
48/// NnsDataCenterInfoRequest
49///
50#[derive(Clone, Debug, Eq, PartialEq)]
51pub struct NnsDataCenterInfoRequest {
52    pub cache: NnsDataCenterCacheRequest,
53    pub source_endpoint: String,
54    pub input: String,
55    pub now_unix_secs: u64,
56}
57
58impl NnsDataCenterInfoRequest {
59    #[must_use]
60    pub fn new(
61        cache: NnsDataCenterCacheRequest,
62        source_endpoint: impl Into<String>,
63        input: impl Into<String>,
64        now_unix_secs: u64,
65    ) -> Self {
66        Self {
67            cache,
68            source_endpoint: source_endpoint.into(),
69            input: input.into(),
70            now_unix_secs,
71        }
72    }
73}
74
75///
76/// NnsDataCenterRefreshRequest
77///
78#[cfg(feature = "host")]
79#[derive(Clone, Debug, Eq, PartialEq)]
80pub struct NnsDataCenterRefreshRequest {
81    pub cache: NnsDataCenterCacheRequest,
82    pub source_endpoint: String,
83    pub now_unix_secs: u64,
84    pub lock_stale_after_seconds: u64,
85    pub dry_run: bool,
86    pub output_path: Option<PathBuf>,
87}
88
89#[cfg(feature = "host")]
90impl NnsDataCenterRefreshRequest {
91    #[must_use]
92    pub fn new(
93        cache: NnsDataCenterCacheRequest,
94        source_endpoint: impl Into<String>,
95        now_unix_secs: u64,
96        lock_stale_after_seconds: u64,
97    ) -> Self {
98        Self {
99            cache,
100            source_endpoint: source_endpoint.into(),
101            now_unix_secs,
102            lock_stale_after_seconds,
103            dry_run: false,
104            output_path: None,
105        }
106    }
107
108    #[must_use]
109    pub const fn with_dry_run(mut self, dry_run: bool) -> Self {
110        self.dry_run = dry_run;
111        self
112    }
113
114    #[must_use]
115    pub fn with_output_path(mut self, output_path: impl Into<PathBuf>) -> Self {
116        self.output_path = Some(output_path.into());
117        self
118    }
119}
120
121#[cfg(feature = "host")]
122impl_nns_leaf_cache_and_refresh_requests!(NnsDataCenterCacheRequest, NnsDataCenterRefreshRequest);