ic_query/nns/node_provider/report/model/
request.rs1use std::path::PathBuf;
2
3#[derive(Clone, Debug, Eq, PartialEq)]
10pub struct NnsNodeProviderCacheRequest {
11 pub icp_root: PathBuf,
12 pub network: String,
13}
14
15impl NnsNodeProviderCacheRequest {
16 #[must_use]
17 pub fn new(icp_root: impl Into<PathBuf>, network: impl Into<String>) -> Self {
18 Self {
19 icp_root: icp_root.into(),
20 network: network.into(),
21 }
22 }
23}
24
25#[derive(Clone, Debug, Eq, PartialEq)]
32pub struct NnsNodeProviderListRequest {
33 pub cache: NnsNodeProviderCacheRequest,
34 pub source_endpoint: String,
35 pub now_unix_secs: u64,
36}
37
38impl NnsNodeProviderListRequest {
39 #[must_use]
40 pub fn new(
41 cache: NnsNodeProviderCacheRequest,
42 source_endpoint: impl Into<String>,
43 now_unix_secs: u64,
44 ) -> Self {
45 Self {
46 cache,
47 source_endpoint: source_endpoint.into(),
48 now_unix_secs,
49 }
50 }
51}
52
53#[derive(Clone, Debug, Eq, PartialEq)]
60pub struct NnsNodeProviderInfoRequest {
61 pub cache: NnsNodeProviderCacheRequest,
62 pub source_endpoint: String,
63 pub input: String,
64 pub now_unix_secs: u64,
65}
66
67impl NnsNodeProviderInfoRequest {
68 #[must_use]
69 pub fn new(
70 cache: NnsNodeProviderCacheRequest,
71 source_endpoint: impl Into<String>,
72 input: impl Into<String>,
73 now_unix_secs: u64,
74 ) -> Self {
75 Self {
76 cache,
77 source_endpoint: source_endpoint.into(),
78 input: input.into(),
79 now_unix_secs,
80 }
81 }
82}
83
84#[cfg(feature = "host")]
91#[derive(Clone, Debug, Eq, PartialEq)]
92pub struct NnsNodeProviderRefreshRequest {
93 pub cache: NnsNodeProviderCacheRequest,
94 pub source_endpoint: String,
95 pub now_unix_secs: u64,
96 pub lock_stale_after_seconds: u64,
97 pub dry_run: bool,
98 pub output_path: Option<PathBuf>,
99}
100
101#[cfg(feature = "host")]
102impl NnsNodeProviderRefreshRequest {
103 #[must_use]
104 pub fn new(
105 cache: NnsNodeProviderCacheRequest,
106 source_endpoint: impl Into<String>,
107 now_unix_secs: u64,
108 lock_stale_after_seconds: u64,
109 ) -> Self {
110 Self {
111 cache,
112 source_endpoint: source_endpoint.into(),
113 now_unix_secs,
114 lock_stale_after_seconds,
115 dry_run: false,
116 output_path: None,
117 }
118 }
119
120 #[must_use]
121 pub const fn with_dry_run(mut self, dry_run: bool) -> Self {
122 self.dry_run = dry_run;
123 self
124 }
125
126 #[must_use]
127 pub fn with_output_path(mut self, output_path: impl Into<PathBuf>) -> Self {
128 self.output_path = Some(output_path.into());
129 self
130 }
131}
132
133#[cfg(feature = "host")]
134impl_nns_leaf_cache_and_refresh_requests!(
135 NnsNodeProviderCacheRequest,
136 NnsNodeProviderRefreshRequest
137);