use crate::sns::report::{
SnsHostError,
cache_storage::SnsCacheStorageFamily,
neurons_cache::{
SNS_NEURONS_CACHE_SCHEMA_VERSION,
model::{SNS_NEURONS_CACHE_FIELDS, SnsNeuronsCacheRows},
paths::SnsNeuronsCacheCollection,
},
source::validate_sns_neuron_rows,
};
use std::path::PathBuf;
mod lookup;
pub(super) use lookup::load_sns_neurons_cache_for_input;
impl SnsCacheStorageFamily for SnsNeuronsCacheCollection {
type Data = SnsNeuronsCacheRows;
const CACHE_SCHEMA_VERSION: u32 = SNS_NEURONS_CACHE_SCHEMA_VERSION;
const CACHE_FIELDS: &'static [&'static str] = SNS_NEURONS_CACHE_FIELDS;
const CACHE_ITEM_NAME: &'static str = "neuron";
fn missing_cache_error(path: PathBuf) -> SnsHostError {
SnsHostError::MissingNeuronsCache { path }
}
fn row_count(data: &Self::Data) -> usize {
data.neurons.len()
}
fn validate_rows(data: &Self::Data) -> Result<(), String> {
validate_sns_neuron_rows(&data.neurons)
}
}