Skip to main content

ic_query/sns/report/model/reports/neurons/
cache.rs

1//! Module: sns::report::model::reports::neurons::cache
2//!
3//! Responsibility: local SNS neuron cache inspection report DTOs.
4//! Does not own: cache discovery, refresh-attempt reads, or rendering.
5//! Boundary: preserves cache summary fields for cache list/status output.
6
7use super::SnsNeuronsRefreshAttemptStatus;
8use crate::sns::report::SnsCacheSummarySortKey;
9use serde::Serialize;
10
11///
12/// SnsNeuronsCacheListReport
13///
14/// Serializable report listing complete local SNS neuron caches.
15///
16
17#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
18pub struct SnsNeuronsCacheListReport {
19    pub schema_version: u32,
20    pub network: String,
21    pub cache_root: String,
22    pub cache_count: usize,
23    pub caches: Vec<SnsNeuronsCacheSummary>,
24}
25
26///
27/// SnsNeuronsCacheStatusReport
28///
29/// Serializable report describing one expected or discovered SNS neuron cache.
30///
31
32#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
33pub struct SnsNeuronsCacheStatusReport {
34    pub schema_version: u32,
35    pub network: String,
36    pub cache_root: String,
37    pub input: String,
38    pub found: bool,
39    pub cache: Option<SnsNeuronsCacheSummary>,
40    pub expected_cache_path: Option<String>,
41    pub refresh_attempt_path: Option<String>,
42    pub latest_attempt: Option<SnsNeuronsRefreshAttemptStatus>,
43}
44
45///
46/// SnsNeuronsCacheSummary
47///
48/// Serializable summary of one complete SNS neuron snapshot cache.
49///
50
51#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
52pub struct SnsNeuronsCacheSummary {
53    pub id: usize,
54    pub name: String,
55    pub root_canister_id: String,
56    pub governance_canister_id: String,
57    pub cache_status: String,
58    pub cache_error: Option<String>,
59    pub complete: bool,
60    pub row_count: usize,
61    pub page_count: u32,
62    pub page_size: u32,
63    pub fetched_at: String,
64    pub source_endpoint: String,
65    pub cache_path: String,
66    pub refresh_attempt_path: String,
67    pub latest_attempt: Option<SnsNeuronsRefreshAttemptStatus>,
68}
69
70impl SnsCacheSummarySortKey for SnsNeuronsCacheSummary {
71    fn id(&self) -> usize {
72        self.id
73    }
74
75    fn root_canister_id(&self) -> &str {
76        &self.root_canister_id
77    }
78
79    fn cache_path(&self) -> &str {
80        &self.cache_path
81    }
82
83    fn cache_error(&self) -> Option<&str> {
84        self.cache_error.as_deref()
85    }
86}