use serde::Serialize;
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct IcCanisterRequest {
pub source_endpoint: String,
pub now_unix_secs: u64,
pub canister_id: String,
}
impl IcCanisterRequest {
#[must_use]
pub fn new(
source_endpoint: impl Into<String>,
now_unix_secs: u64,
canister_id: impl Into<String>,
) -> Self {
Self {
source_endpoint: source_endpoint.into(),
now_unix_secs,
canister_id: canister_id.into(),
}
}
}
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize)]
pub struct IcCanisterFilters {
pub has_name: Option<bool>,
pub subnet_id: Option<String>,
pub controller_id: Option<String>,
pub languages: Vec<String>,
pub canister_types: Vec<String>,
pub query: Option<String>,
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct IcCanisterCountRequest {
pub source_endpoint: String,
pub now_unix_secs: u64,
pub filters: IcCanisterFilters,
}
impl IcCanisterCountRequest {
#[must_use]
pub fn new(source_endpoint: impl Into<String>, now_unix_secs: u64) -> Self {
Self {
source_endpoint: source_endpoint.into(),
now_unix_secs,
filters: IcCanisterFilters::default(),
}
}
#[must_use]
pub fn with_filters(mut self, filters: IcCanisterFilters) -> Self {
self.filters = filters;
self
}
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct IcCanisterPageRequest {
pub source_endpoint: String,
pub now_unix_secs: u64,
pub filters: IcCanisterFilters,
pub limit: u16,
pub after: Option<String>,
pub before: Option<String>,
}
impl IcCanisterPageRequest {
#[must_use]
pub fn new(source_endpoint: impl Into<String>, now_unix_secs: u64) -> Self {
Self {
source_endpoint: source_endpoint.into(),
now_unix_secs,
filters: IcCanisterFilters::default(),
limit: crate::ic::DEFAULT_IC_CANISTER_PAGE_LIMIT,
after: None,
before: None,
}
}
#[must_use]
pub fn with_filters(mut self, filters: IcCanisterFilters) -> Self {
self.filters = filters;
self
}
#[must_use]
pub const fn with_limit(mut self, limit: u16) -> Self {
self.limit = limit;
self
}
#[must_use]
pub fn with_after(mut self, after: impl Into<String>) -> Self {
self.after = Some(after.into());
self
}
#[must_use]
pub fn with_before(mut self, before: impl Into<String>) -> Self {
self.before = Some(before.into());
self
}
}