Skip to main content

canic_core/dto/
cascade.rs

1use crate::dto::{prelude::*, state::FleetStateInput};
2//
3// StateSnapshotInput
4//
5// Cascade state snapshot.
6//
7
8#[derive(CandidType, Clone, Debug, Deserialize)]
9pub struct StateSnapshotInput {
10    pub fleet_state: Option<FleetStateInput>,
11}
12
13/// One observed result; an unconfirmed call may have applied before its reply was lost.
14#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq)]
15pub enum StateCascadeTargetResult {
16    Applied,
17    AppliedWithReconciliationFailure(crate::dto::error::Error),
18    Unconfirmed(crate::dto::error::Error),
19}
20
21/// Exact canister associated with one bounded state-cascade observation.
22#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq)]
23pub struct StateCascadeTargetOutcome {
24    pub canister_id: Principal,
25    pub result: StateCascadeTargetResult,
26}
27
28/// Aggregate observations retain full counts when the bounded detail list fills.
29#[derive(CandidType, Clone, Debug, Default, Deserialize, Eq, PartialEq)]
30pub struct StateCascadeReport {
31    pub successful_targets: u64,
32    pub reconciliation_failures: u64,
33    pub unconfirmed_targets: u64,
34    pub omitted_targets: u64,
35    pub targets: Vec<StateCascadeTargetOutcome>,
36}
37
38//
39// TopologySnapshotInput
40//
41// Cascade topology snapshot.
42//
43
44#[derive(CandidType, Clone, Debug, Deserialize)]
45pub struct TopologySnapshotInput {
46    pub parents: Vec<TopologyPathNode>,
47    // Children keyed by parent pid.
48    pub children_map: Vec<TopologyChildren>,
49}
50
51//
52// TopologyChildren
53//
54// Parent-keyed child list.
55//
56
57#[derive(CandidType, Clone, Debug, Deserialize)]
58pub struct TopologyChildren {
59    pub parent_pid: Principal,
60    pub children: Vec<TopologyDirectChild>,
61}
62
63//
64// TopologyDirectChild
65//
66// Direct child node.
67//
68
69#[derive(CandidType, Clone, Debug, Deserialize)]
70pub struct TopologyDirectChild {
71    pub pid: Principal,
72    pub role: CanisterRole,
73}
74
75//
76// TopologyPathNode
77//
78// Parent-path node.
79//
80
81#[derive(CandidType, Clone, Debug, Deserialize)]
82pub struct TopologyPathNode {
83    pub pid: Principal,
84    pub role: CanisterRole,
85    pub parent_pid: Option<Principal>,
86}