Skip to main content

canic_core/dto/
state.rs

1use crate::dto::prelude::*;
2
3//
4// AppCommand
5//
6
7#[derive(CandidType, Clone, Copy, Debug, Deserialize, Eq, PartialEq)]
8pub enum AppCommand {
9    SetStatus(AppStatus),
10    SetCyclesFundingEnabled(bool),
11}
12
13//
14// AppCommandResponse
15//
16
17#[derive(CandidType, Clone, Copy, Debug, Deserialize, Eq, PartialEq)]
18pub enum AppCommandResponse {
19    Status(SetStateResponse<AppStatus>),
20    CyclesFundingEnabled(SetStateResponse<bool>),
21}
22
23//
24// SetStateResponse
25//
26
27#[derive(CandidType, Clone, Copy, Debug, Deserialize, Eq, PartialEq)]
28pub struct SetStateResponse<T> {
29    pub previous: T,
30    pub current: T,
31    pub changed: bool,
32}
33
34//
35// AppStatus
36//
37
38#[derive(CandidType, Clone, Copy, Debug, Deserialize, Eq, PartialEq)]
39pub enum AppStatus {
40    Active,
41    Readonly,
42    Stopped,
43}
44
45//
46// AppMode
47//
48
49#[derive(CandidType, Clone, Copy, Debug, Deserialize, Eq, PartialEq)]
50pub enum AppMode {
51    Enabled,
52    Readonly,
53    Disabled,
54}
55
56//
57// AppStateInput
58//
59
60#[derive(CandidType, Clone, Copy, Debug, Deserialize, Eq, PartialEq)]
61pub struct AppStateInput {
62    pub mode: AppMode,
63    pub cycles_funding_enabled: bool,
64}
65
66//
67// AppStateResponse
68//
69
70#[derive(CandidType, Deserialize)]
71pub struct AppStateResponse {
72    pub mode: AppMode,
73    pub cycles_funding_enabled: bool,
74}
75
76//
77// SubnetAuthStateInput
78//
79
80#[derive(CandidType, Clone, Debug, Default, Deserialize, Eq, PartialEq)]
81pub struct SubnetAuthStateInput {}
82
83//
84// SubnetStateInput
85//
86
87#[derive(CandidType, Clone, Debug, Default, Deserialize, Eq, PartialEq)]
88pub struct SubnetStateInput {
89    pub auth: SubnetAuthStateInput,
90}
91
92//
93// SubnetStateResponse
94//
95
96#[derive(CandidType, Clone, Debug, Default, Deserialize, Eq, PartialEq)]
97pub struct SubnetStateResponse {
98    pub auth: SubnetAuthStateInput,
99}
100
101//
102// BootstrapStatusResponse
103//
104
105#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq)]
106pub struct BootstrapStatusResponse {
107    pub ready: bool,
108    pub phase: String,
109    pub last_error: Option<String>,
110}