canic_core/dto/
cascade.rs

1use crate::dto::{
2    prelude::*,
3    state::{AppStateView, SubnetStateView},
4    topology::{AppDirectoryView, SubnetDirectoryView},
5};
6
7///
8/// StateSnapshotView
9/// Snapshot of mutable state and directory sections that can be propagated to peers.
10/// Pure DTO.
11///
12
13#[derive(CandidType, Clone, Debug, Deserialize)]
14pub struct StateSnapshotView {
15    pub app_state: Option<AppStateView>,
16    pub subnet_state: Option<SubnetStateView>,
17    pub app_directory: Option<AppDirectoryView>,
18    pub subnet_directory: Option<SubnetDirectoryView>,
19}
20
21///
22/// TopologySnapshotView
23/// Partial topology snapshot used for cascade.
24/// Contains:
25/// - a parent path (root -> target)
26/// - direct children for each node on that path only
27///
28/// This is not a full topology export.
29///
30/// Pure DTO.
31///
32
33#[derive(CandidType, Clone, Debug, Deserialize)]
34pub struct TopologySnapshotView {
35    pub parents: Vec<TopologyPathNodeView>,
36    /// Children keyed by their parent pid (at most one entry per parent).
37    pub children_map: Vec<TopologyChildrenView>,
38}
39
40///
41/// TopologyChildrenView
42/// Parent-keyed children list used in topology cascades.
43///
44
45#[derive(CandidType, Clone, Debug, Deserialize)]
46pub struct TopologyChildrenView {
47    pub parent_pid: Principal,
48    pub children: Vec<TopologyDirectChildView>,
49}
50
51///
52/// TopologyDirectChildView
53/// Direct child node for parent-keyed topology maps.
54///
55
56#[derive(CandidType, Clone, Debug, Deserialize)]
57pub struct TopologyDirectChildView {
58    pub pid: Principal,
59    pub role: CanisterRole,
60}
61
62///
63/// TopologyPathNodeView
64/// Snapshot node for parent-path traversal (includes identity).
65///
66
67#[derive(CandidType, Clone, Debug, Deserialize)]
68pub struct TopologyPathNodeView {
69    pub pid: Principal,
70    pub role: CanisterRole,
71    pub parent_pid: Option<Principal>,
72}