use super::lookup::SnsLookupRequest;
use crate::sns::report::SnsNeuronsCacheSort;
use std::path::PathBuf;
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct SnsNeuronRequest {
pub lookup: SnsLookupRequest,
pub neuron_id: String,
}
impl SnsNeuronRequest {
#[must_use]
pub fn new(lookup: SnsLookupRequest, neuron_id: impl Into<String>) -> Self {
Self {
lookup,
neuron_id: neuron_id.into(),
}
}
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum SnsNeuronCollection {
Live {
owner_principal_id: Option<String>,
},
Cached {
cache_root: PathBuf,
sort: SnsNeuronsCacheSort,
},
}
impl SnsNeuronCollection {
pub(in crate::sns::report) const fn sort_label(&self) -> &'static str {
match self {
Self::Live { .. } => "api",
Self::Cached { sort, .. } => sort.as_str(),
}
}
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct SnsNeuronsRequest {
pub lookup: SnsLookupRequest,
pub limit: u32,
pub collection: SnsNeuronCollection,
}
impl SnsNeuronsRequest {
#[must_use]
pub const fn live(
lookup: SnsLookupRequest,
limit: u32,
owner_principal_id: Option<String>,
) -> Self {
Self {
lookup,
limit,
collection: SnsNeuronCollection::Live { owner_principal_id },
}
}
#[must_use]
pub fn cached(
lookup: SnsLookupRequest,
limit: u32,
cache_root: impl Into<PathBuf>,
sort: SnsNeuronsCacheSort,
) -> Self {
Self {
lookup,
limit,
collection: SnsNeuronCollection::Cached {
cache_root: cache_root.into(),
sort,
},
}
}
}