Skip to main content

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

1use std::path::PathBuf;
2
3///
4/// NnsNodeCacheRequest
5///
6#[derive(Clone, Debug, Eq, PartialEq)]
7pub struct NnsNodeCacheRequest {
8    pub icp_root: PathBuf,
9    pub network: String,
10}
11
12impl NnsNodeCacheRequest {
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/// NnsNodeListRequest
24///
25#[derive(Clone, Debug, Eq, PartialEq)]
26pub struct NnsNodeListRequest {
27    pub cache: NnsNodeCacheRequest,
28    pub source_endpoint: String,
29    pub now_unix_secs: u64,
30    pub filters: NnsNodeListFilters,
31}
32
33///
34/// NnsNodeInfoRequest
35///
36#[derive(Clone, Debug, Eq, PartialEq)]
37pub struct NnsNodeInfoRequest {
38    pub cache: NnsNodeCacheRequest,
39    pub source_endpoint: String,
40    pub input: String,
41    pub now_unix_secs: u64,
42}
43
44///
45/// NnsNodeRefreshRequest
46///
47#[cfg(feature = "host")]
48#[derive(Clone, Debug, Eq, PartialEq)]
49pub struct NnsNodeRefreshRequest {
50    pub cache: NnsNodeCacheRequest,
51    pub source_endpoint: String,
52    pub now_unix_secs: u64,
53    pub lock_stale_after_seconds: u64,
54    pub dry_run: bool,
55    pub output_path: Option<PathBuf>,
56}
57
58#[cfg(feature = "host")]
59impl_nns_leaf_cache_and_refresh_requests!(NnsNodeCacheRequest, NnsNodeRefreshRequest);
60
61///
62/// NnsNodeListFilters
63///
64#[derive(Clone, Debug, Default, Eq, PartialEq)]
65pub struct NnsNodeListFilters {
66    pub subnet: Option<String>,
67    pub subnet_kind: Option<String>,
68    pub data_center: Option<String>,
69    pub node_provider: Option<String>,
70    pub node_operator: Option<String>,
71}
72
73impl NnsNodeListFilters {
74    #[must_use]
75    pub const fn is_empty(&self) -> bool {
76        self.subnet.is_none()
77            && self.subnet_kind.is_none()
78            && self.data_center.is_none()
79            && self.node_provider.is_none()
80            && self.node_operator.is_none()
81    }
82}