ic_query/nns/node_provider/report/model/
request.rs1use std::path::PathBuf;
2
3#[derive(Clone, Debug, Eq, PartialEq)]
7pub struct NnsNodeProviderCacheRequest {
8 pub icp_root: PathBuf,
9 pub network: String,
10}
11
12impl NnsNodeProviderCacheRequest {
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#[derive(Clone, Debug, Eq, PartialEq)]
26pub struct NnsNodeProviderListRequest {
27 pub cache: NnsNodeProviderCacheRequest,
28 pub source_endpoint: String,
29 pub now_unix_secs: u64,
30}
31
32impl NnsNodeProviderListRequest {
33 #[must_use]
34 pub fn new(
35 cache: NnsNodeProviderCacheRequest,
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#[derive(Clone, Debug, Eq, PartialEq)]
51pub struct NnsNodeProviderInfoRequest {
52 pub cache: NnsNodeProviderCacheRequest,
53 pub source_endpoint: String,
54 pub input: String,
55 pub now_unix_secs: u64,
56}
57
58impl NnsNodeProviderInfoRequest {
59 #[must_use]
60 pub fn new(
61 cache: NnsNodeProviderCacheRequest,
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#[cfg(feature = "host")]
79#[derive(Clone, Debug, Eq, PartialEq)]
80pub struct NnsNodeProviderRefreshRequest {
81 pub cache: NnsNodeProviderCacheRequest,
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 NnsNodeProviderRefreshRequest {
91 #[must_use]
92 pub fn new(
93 cache: NnsNodeProviderCacheRequest,
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!(
123 NnsNodeProviderCacheRequest,
124 NnsNodeProviderRefreshRequest
125);