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#[cfg(feature = "nns-host")]
60impl NnsInventoryListRequest {
61 #[must_use]
63 pub fn source_request(&self) -> crate::report::CollectionSourceRequest {
64 crate::report::CollectionSourceRequest::from_unix_secs(
65 &self.cache.network,
66 &self.source_endpoint,
67 self.now_unix_secs,
68 "ic-query",
69 )
70 }
71}
72
73#[derive(Clone, Debug, Eq, PartialEq)]
80pub struct NnsInventoryInfoRequest {
81 pub cache: NnsInventoryCacheRequest,
82 pub source_endpoint: String,
83 pub input: String,
84 pub now_unix_secs: u64,
85}
86
87impl NnsInventoryInfoRequest {
88 #[cfg(feature = "nns-host")]
89 pub(in crate::nns) fn to_list_request(&self) -> NnsInventoryListRequest {
90 NnsInventoryListRequest {
91 cache: self.cache.clone(),
92 source_endpoint: self.source_endpoint.clone(),
93 now_unix_secs: self.now_unix_secs,
94 }
95 }
96
97 #[must_use]
98 pub fn new(
99 cache: NnsInventoryCacheRequest,
100 source_endpoint: impl Into<String>,
101 input: impl Into<String>,
102 now_unix_secs: u64,
103 ) -> Self {
104 Self {
105 cache,
106 source_endpoint: source_endpoint.into(),
107 input: input.into(),
108 now_unix_secs,
109 }
110 }
111}
112
113#[cfg(feature = "nns-host")]
120#[derive(Clone, Debug, Eq, PartialEq)]
121pub struct NnsInventoryRefreshRequest {
122 pub cache: NnsInventoryCacheRequest,
123 pub source_endpoint: String,
124 pub now_unix_secs: u64,
125
126 pub dry_run: bool,
127 pub output_path: Option<PathBuf>,
128}
129
130#[cfg(feature = "nns-host")]
131impl NnsInventoryRefreshRequest {
132 #[must_use]
133 pub fn new(
134 cache: NnsInventoryCacheRequest,
135 source_endpoint: impl Into<String>,
136 now_unix_secs: u64,
137 ) -> Self {
138 Self {
139 cache,
140 source_endpoint: source_endpoint.into(),
141 now_unix_secs,
142
143 dry_run: false,
144 output_path: None,
145 }
146 }
147}