ic-query 0.5.3

Internet Computer query library for NNS, SNS, ICRC, and related public network metadata
Documentation
//! Module: sns::report::neurons_cache::storage::load
//!
//! Responsibility: load one complete SNS neuron cache snapshot from disk.
//! Does not own: lookup resolution, cache path construction, refresh, or rendering.
//! Boundary: validates schema, network, and completeness before returning a cache model.

use super::errors::{SnsNeuronsCacheErrors, incomplete_cache_error};
use crate::sns::report::{
    SnsHostError,
    cache_storage::load_sns_complete_cache,
    neurons_cache::{
        SNS_NEURONS_CACHE_SCHEMA_VERSION, model::SnsNeuronsCache,
        paths::sns_neurons_cache_key_for_cache_path,
    },
};
use std::path::PathBuf;

pub(in crate::sns::report::neurons_cache) fn load_sns_neurons_cache_at(
    path: PathBuf,
    network: &str,
) -> Result<SnsNeuronsCache, SnsHostError> {
    let key = sns_neurons_cache_key_for_cache_path(network, &path);
    load_sns_complete_cache(
        path,
        network,
        SNS_NEURONS_CACHE_SCHEMA_VERSION,
        &key,
        SnsNeuronsCacheErrors,
        |completeness| incomplete_cache_error(completeness.page_count, completeness.row_count),
    )
}