ic_query/nns/
inventory_request.rs1use std::path::PathBuf;
8
9#[derive(Clone, Debug, Eq, PartialEq)]
16pub struct NnsInventoryCacheRequest {
17 pub cache_root: PathBuf,
18 pub network: String,
19}
20
21impl NnsInventoryCacheRequest {
22 #[must_use]
23 pub fn new(cache_root: impl Into<PathBuf>, network: impl Into<String>) -> Self {
24 Self {
25 cache_root: cache_root.into(),
26 network: network.into(),
27 }
28 }
29}
30
31#[derive(Clone, Debug, Eq, PartialEq)]
38pub struct NnsInventoryListRequest {
39 pub cache: NnsInventoryCacheRequest,
40 pub source_endpoint: String,
41 pub now_unix_secs: u64,
42}
43
44impl NnsInventoryListRequest {
45 #[must_use]
46 pub fn new(
47 cache: NnsInventoryCacheRequest,
48 source_endpoint: impl Into<String>,
49 now_unix_secs: u64,
50 ) -> Self {
51 Self {
52 cache,
53 source_endpoint: source_endpoint.into(),
54 now_unix_secs,
55 }
56 }
57}
58
59#[derive(Clone, Debug, Eq, PartialEq)]
66pub struct NnsInventoryInfoRequest {
67 pub cache: NnsInventoryCacheRequest,
68 pub source_endpoint: String,
69 pub input: String,
70 pub now_unix_secs: u64,
71}
72
73impl NnsInventoryInfoRequest {
74 #[must_use]
75 pub fn new(
76 cache: NnsInventoryCacheRequest,
77 source_endpoint: impl Into<String>,
78 input: impl Into<String>,
79 now_unix_secs: u64,
80 ) -> Self {
81 Self {
82 cache,
83 source_endpoint: source_endpoint.into(),
84 input: input.into(),
85 now_unix_secs,
86 }
87 }
88}
89
90#[cfg(feature = "host")]
97#[derive(Clone, Debug, Eq, PartialEq)]
98pub struct NnsInventoryRefreshRequest {
99 pub cache: NnsInventoryCacheRequest,
100 pub source_endpoint: String,
101 pub now_unix_secs: u64,
102 pub lock_stale_after_seconds: u64,
103 pub dry_run: bool,
104 pub output_path: Option<PathBuf>,
105}
106
107#[cfg(feature = "host")]
108impl NnsInventoryRefreshRequest {
109 #[must_use]
110 pub fn new(
111 cache: NnsInventoryCacheRequest,
112 source_endpoint: impl Into<String>,
113 now_unix_secs: u64,
114 lock_stale_after_seconds: u64,
115 ) -> Self {
116 Self {
117 cache,
118 source_endpoint: source_endpoint.into(),
119 now_unix_secs,
120 lock_stale_after_seconds,
121 dry_run: false,
122 output_path: None,
123 }
124 }
125
126 #[must_use]
127 pub const fn with_dry_run(mut self, dry_run: bool) -> Self {
128 self.dry_run = dry_run;
129 self
130 }
131
132 #[must_use]
133 pub fn with_output_path(mut self, output_path: impl Into<PathBuf>) -> Self {
134 self.output_path = Some(output_path.into());
135 self
136 }
137}
138
139#[cfg(feature = "host")]
140impl_nns_leaf_cache_and_refresh_requests!(NnsInventoryCacheRequest, NnsInventoryRefreshRequest);