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/// `Default` represents an empty snapshot (all sections omitted). This is used for
13/// internal snapshot assembly; it must not be interpreted as an intentional or
14/// complete payload.
15///
16
17#[derive(CandidType, Clone, Debug, Default, Deserialize)]
18pub struct StateSnapshotView {
19    pub app_state: Option<AppStateView>,
20    pub subnet_state: Option<SubnetStateView>,
21    pub app_directory: Option<AppDirectoryView>,
22    pub subnet_directory: Option<SubnetDirectoryView>,
23}
24
25///
26/// TopologySnapshotView
27/// Partial topology snapshot used for cascade.
28/// Contains:
29/// - a parent path (root -> target)
30/// - direct children for each node on that path only
31///
32/// This is not a full topology export.
33///
34/// Pure DTO.
35///
36
37#[derive(CandidType, Clone, Debug, Deserialize)]
38pub struct TopologySnapshotView {
39    pub parents: Vec<TopologyPathNodeView>,
40    /// Children keyed by their parent pid (at most one entry per parent).
41    pub children_map: Vec<TopologyChildrenView>,
42}
43
44///
45/// TopologyChildrenView
46/// Parent-keyed children list used in topology cascades.
47///
48
49#[derive(CandidType, Clone, Debug, Deserialize)]
50pub struct TopologyChildrenView {
51    pub parent_pid: Principal,
52    pub children: Vec<TopologyDirectChildView>,
53}
54
55///
56/// TopologyDirectChildView
57/// Direct child node for parent-keyed topology maps.
58///
59
60#[derive(CandidType, Clone, Debug, Deserialize)]
61pub struct TopologyDirectChildView {
62    pub pid: Principal,
63    pub role: CanisterRole,
64}
65
66///
67/// TopologyPathNodeView
68/// Snapshot node for parent-path traversal (includes identity).
69///
70
71#[derive(CandidType, Clone, Debug, Deserialize)]
72pub struct TopologyPathNodeView {
73    pub pid: Principal,
74    pub role: CanisterRole,
75    pub parent_pid: Option<Principal>,
76}