Skip to main content

canic_core/dto/
state.rs

1use crate::dto::prelude::*;
2use crate::ids::WasmStoreBinding;
3
4///
5/// AppCommand
6///
7
8#[derive(CandidType, Clone, Copy, Debug, Deserialize, Eq, PartialEq)]
9pub enum AppCommand {
10    SetStatus(AppStatus),
11    SetCyclesFundingEnabled(bool),
12}
13
14///
15/// AppStatus
16///
17
18#[derive(CandidType, Clone, Copy, Debug, Deserialize, Eq, PartialEq)]
19pub enum AppStatus {
20    Active,
21    Readonly,
22    Stopped,
23}
24
25///
26/// AppMode
27///
28
29#[derive(CandidType, Clone, Copy, Debug, Deserialize, Eq, PartialEq)]
30pub enum AppMode {
31    Enabled,
32    Readonly,
33    Disabled,
34}
35
36///
37/// AppStateInput
38///
39
40#[derive(CandidType, Clone, Copy, Debug, Deserialize, Eq, PartialEq)]
41pub struct AppStateInput {
42    pub mode: AppMode,
43    pub cycles_funding_enabled: bool,
44}
45
46///
47/// AppStateResponse
48///
49
50#[derive(CandidType, Deserialize)]
51pub struct AppStateResponse {
52    pub mode: AppMode,
53    pub cycles_funding_enabled: bool,
54}
55
56///
57/// SubnetStateInput
58///
59
60#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq)]
61pub struct WasmStoreStateInput {
62    pub binding: WasmStoreBinding,
63    pub pid: Principal,
64    pub created_at: u64,
65}
66
67///
68/// SubnetStateInput
69///
70
71#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq)]
72pub struct SubnetStateInput {
73    pub wasm_stores: Option<Vec<WasmStoreStateInput>>,
74}
75
76///
77/// SubnetStateResponse
78///
79
80#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq)]
81pub struct WasmStoreStateResponse {
82    pub binding: WasmStoreBinding,
83    pub pid: Principal,
84    pub created_at: u64,
85}
86
87#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq)]
88pub struct SubnetStateResponse {
89    pub wasm_stores: Vec<WasmStoreStateResponse>,
90}