use std::path::PathBuf;
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct NnsInventoryCacheRequest {
pub cache_root: PathBuf,
pub network: String,
}
impl NnsInventoryCacheRequest {
#[must_use]
pub fn new(cache_root: impl Into<PathBuf>, network: impl Into<String>) -> Self {
Self {
cache_root: cache_root.into(),
network: network.into(),
}
}
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct NnsInventoryListRequest {
pub cache: NnsInventoryCacheRequest,
pub source_endpoint: String,
pub now_unix_secs: u64,
}
impl NnsInventoryListRequest {
#[must_use]
pub fn new(
cache: NnsInventoryCacheRequest,
source_endpoint: impl Into<String>,
now_unix_secs: u64,
) -> Self {
Self {
cache,
source_endpoint: source_endpoint.into(),
now_unix_secs,
}
}
}
#[cfg(feature = "nns-host")]
impl NnsInventoryListRequest {
#[must_use]
pub fn source_request(&self) -> crate::report::CollectionSourceRequest {
crate::report::CollectionSourceRequest::from_unix_secs(
&self.cache.network,
&self.source_endpoint,
self.now_unix_secs,
"ic-query",
)
}
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct NnsInventoryInfoRequest {
pub cache: NnsInventoryCacheRequest,
pub source_endpoint: String,
pub input: String,
pub now_unix_secs: u64,
}
impl NnsInventoryInfoRequest {
#[cfg(feature = "nns-host")]
pub(in crate::nns) fn to_list_request(&self) -> NnsInventoryListRequest {
NnsInventoryListRequest {
cache: self.cache.clone(),
source_endpoint: self.source_endpoint.clone(),
now_unix_secs: self.now_unix_secs,
}
}
#[must_use]
pub fn new(
cache: NnsInventoryCacheRequest,
source_endpoint: impl Into<String>,
input: impl Into<String>,
now_unix_secs: u64,
) -> Self {
Self {
cache,
source_endpoint: source_endpoint.into(),
input: input.into(),
now_unix_secs,
}
}
}
#[cfg(feature = "nns-host")]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct NnsInventoryRefreshRequest {
pub cache: NnsInventoryCacheRequest,
pub source_endpoint: String,
pub now_unix_secs: u64,
pub dry_run: bool,
pub output_path: Option<PathBuf>,
}
#[cfg(feature = "nns-host")]
impl NnsInventoryRefreshRequest {
#[must_use]
pub fn new(
cache: NnsInventoryCacheRequest,
source_endpoint: impl Into<String>,
now_unix_secs: u64,
) -> Self {
Self {
cache,
source_endpoint: source_endpoint.into(),
now_unix_secs,
dry_run: false,
output_path: None,
}
}
#[must_use]
pub const fn with_dry_run(mut self, dry_run: bool) -> Self {
self.dry_run = dry_run;
self
}
#[must_use]
pub fn with_output_path(mut self, output_path: impl Into<PathBuf>) -> Self {
self.output_path = Some(output_path.into());
self
}
}