Skip to main content

canic_backup/manifest/
types.rs

1use serde::{Deserialize, Serialize};
2
3///
4/// FleetBackupManifest
5///
6
7#[derive(Clone, Debug, Deserialize, Serialize)]
8pub struct FleetBackupManifest {
9    pub manifest_version: u16,
10    pub backup_id: String,
11    pub created_at: String,
12    pub tool: ToolMetadata,
13    pub source: SourceMetadata,
14    pub consistency: ConsistencySection,
15    pub fleet: FleetSection,
16    pub verification: VerificationPlan,
17}
18
19///
20/// ToolMetadata
21///
22
23#[derive(Clone, Debug, Deserialize, Serialize)]
24pub struct ToolMetadata {
25    pub name: String,
26    pub version: String,
27}
28
29///
30/// SourceMetadata
31///
32
33#[derive(Clone, Debug, Deserialize, Serialize)]
34pub struct SourceMetadata {
35    pub environment: String,
36    pub root_canister: String,
37}
38
39///
40/// ConsistencySection
41///
42
43#[derive(Clone, Debug, Deserialize, Serialize)]
44pub struct ConsistencySection {
45    pub backup_units: Vec<BackupUnit>,
46}
47
48///
49/// BackupUnit
50///
51
52#[derive(Clone, Debug, Deserialize, Serialize)]
53pub struct BackupUnit {
54    pub unit_id: String,
55    pub kind: BackupUnitKind,
56    pub roles: Vec<String>,
57}
58
59///
60/// BackupUnitKind
61///
62
63#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
64#[serde(rename_all = "kebab-case")]
65pub enum BackupUnitKind {
66    Single,
67    Subtree,
68}
69
70///
71/// FleetSection
72///
73
74#[derive(Clone, Debug, Deserialize, Serialize)]
75pub struct FleetSection {
76    pub topology_hash_algorithm: String,
77    pub topology_hash_input: String,
78    pub discovery_topology_hash: String,
79    pub pre_snapshot_topology_hash: String,
80    pub topology_hash: String,
81    pub members: Vec<FleetMember>,
82}
83
84///
85/// FleetMember
86///
87
88#[derive(Clone, Debug, Deserialize, Serialize)]
89pub struct FleetMember {
90    pub role: String,
91    pub canister_id: String,
92    pub parent_canister_id: Option<String>,
93    pub subnet_canister_id: Option<String>,
94    pub controller_hint: Option<String>,
95    pub identity_mode: IdentityMode,
96    pub verification_checks: Vec<VerificationCheck>,
97    pub source_snapshot: SourceSnapshot,
98}
99
100///
101/// IdentityMode
102///
103
104#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
105#[serde(rename_all = "kebab-case")]
106pub enum IdentityMode {
107    Fixed,
108    Relocatable,
109}
110
111///
112/// SourceSnapshot
113///
114
115#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
116pub struct SourceSnapshot {
117    pub snapshot_id: String,
118    pub module_hash: Option<String>,
119    pub code_version: Option<String>,
120    pub artifact_path: String,
121    pub checksum_algorithm: String,
122    #[serde(default)]
123    pub checksum: Option<String>,
124}
125
126///
127/// VerificationPlan
128///
129
130#[derive(Clone, Debug, Default, Deserialize, Serialize)]
131pub struct VerificationPlan {
132    pub fleet_checks: Vec<VerificationCheck>,
133    pub member_checks: Vec<MemberVerificationChecks>,
134}
135
136///
137/// MemberVerificationChecks
138///
139
140#[derive(Clone, Debug, Deserialize, Serialize)]
141pub struct MemberVerificationChecks {
142    pub role: String,
143    pub checks: Vec<VerificationCheck>,
144}
145
146///
147/// VerificationCheck
148///
149
150#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
151pub struct VerificationCheck {
152    pub kind: String,
153    pub roles: Vec<String>,
154}