Skip to main content

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

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