Skip to main content

ic_query/subnet_catalog/
mod.rs

1//! Cached NNS subnet catalog models, resolution helpers, builders, and renderers.
2
3mod error;
4#[cfg(feature = "subnet-catalog-host")]
5mod host;
6mod json;
7mod model;
8mod principal;
9#[cfg(feature = "subnet-catalog-host")]
10mod report;
11mod resolver;
12#[cfg(feature = "subnet-catalog-host")]
13mod text;
14#[cfg(feature = "subnet-catalog-host")]
15mod time;
16
17pub use error::CatalogError;
18#[cfg(feature = "subnet-catalog-host")]
19pub use host::{
20    CachedSubnetCatalog, SubnetCatalogCacheRequest, SubnetCatalogHostError,
21    SubnetCatalogRefreshRequest, SubnetCatalogSource, load_cached_subnet_catalog,
22    load_or_refresh_subnet_catalog, load_or_refresh_subnet_catalog_with_source,
23    refresh_subnet_catalog, refresh_subnet_catalog_with_source, subnet_catalog_path,
24    subnet_catalog_refresh_lock_path,
25};
26pub use json::{catalog_to_pretty_json, parse_catalog_json};
27pub use model::{
28    ClassificationSource, GeographicScope, RoutingRange, SubnetCatalog, SubnetInfo, SubnetKind,
29    SubnetSpecialization,
30};
31pub use principal::canonical_principal_text;
32pub(crate) use principal::{parse_principal, principal_bytes};
33#[cfg(feature = "subnet-catalog-host")]
34pub(crate) use report::CatalogStaleStatus;
35#[cfg(feature = "subnet-catalog-host")]
36pub use report::{
37    SubnetCatalogFilters, SubnetCatalogInfoReport, SubnetCatalogInfoRequest,
38    SubnetCatalogListReport, SubnetCatalogListRequest, SubnetCatalogRefreshReport,
39    SubnetCatalogSubnetRow, build_subnet_catalog_info_report,
40    build_subnet_catalog_info_report_with_source, build_subnet_catalog_list_report,
41    build_subnet_catalog_list_report_with_source,
42};
43pub use resolver::{ResolveAs, ResolvedSubnet, ResolvedSubnetSubject};
44#[cfg(feature = "subnet-catalog-host")]
45pub use text::{
46    subnet_catalog_info_report_text, subnet_catalog_list_report_text,
47    subnet_catalog_list_report_verbose_text, subnet_catalog_refresh_report_text,
48};
49#[cfg(feature = "host")]
50pub(crate) use time::parse_utc_timestamp_secs;
51#[cfg(feature = "subnet-catalog-host")]
52pub(crate) use time::{catalog_stale_status, format_utc_timestamp_secs};
53
54pub const CATALOG_SCHEMA_VERSION: u32 = 1;
55pub const MAINNET_NETWORK: &str = "ic";
56pub const MAINNET_REGISTRY_CANISTER_ID: &str = "rwlgt-iiaaa-aaaaa-aaaaa-cai";
57#[cfg(feature = "subnet-catalog-host")]
58pub const DEFAULT_STALE_AFTER_SECONDS: u64 = 7 * 24 * 60 * 60;
59#[cfg(feature = "subnet-catalog-host")]
60pub const DEFAULT_REFRESH_LOCK_STALE_SECONDS: u64 = 30 * 60;
61#[cfg(feature = "subnet-catalog-host")]
62pub const DEFAULT_SUBNET_CATALOG_SOURCE_ENDPOINT: &str = "https://icp-api.io";
63#[cfg(feature = "subnet-catalog-host")]
64pub(crate) const SUBNET_CATALOG_LIST_REPORT_SCHEMA_VERSION: u32 = 1;
65#[cfg(feature = "subnet-catalog-host")]
66pub(crate) const SUBNET_CATALOG_INFO_REPORT_SCHEMA_VERSION: u32 = 1;
67#[cfg(feature = "subnet-catalog-host")]
68pub(crate) const SUBNET_CATALOG_REFRESH_REPORT_SCHEMA_VERSION: u32 = 1;
69
70#[cfg(test)]
71mod core_tests;
72#[cfg(all(test, feature = "subnet-catalog-host"))]
73mod tests;