canic_core/dto/
canister.rs1use crate::dto::prelude::*;
2
3#[derive(CandidType, Clone, Debug, Deserialize, Serialize)]
8pub struct CanisterEntryView {
9 pub role: CanisterRole,
10 pub parent_pid: Option<Principal>,
11 pub module_hash: Option<Vec<u8>>,
12 pub created_at: u64,
13}
14
15#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
22pub struct CanisterSummaryView {
23 pub role: CanisterRole,
24 pub parent_pid: Option<Principal>,
25}
26
27#[derive(CandidType, Clone, Debug, Deserialize, Serialize)]
32pub struct CanisterStatusView {
33 pub status: CanisterStatusTypeView,
34 pub settings: CanisterSettingsView,
35 pub module_hash: Option<Vec<u8>>,
36 pub memory_size: Nat,
37 pub memory_metrics: MemoryMetricsView,
38 pub cycles: Nat,
39 pub reserved_cycles: Nat,
40 pub idle_cycles_burned_per_day: Nat,
41 pub query_stats: QueryStatsView,
42}
43
44#[derive(CandidType, Clone, Copy, Debug, Deserialize, Serialize)]
49pub enum CanisterStatusTypeView {
50 #[serde(rename = "running")]
51 Running,
52 #[serde(rename = "stopping")]
53 Stopping,
54 #[serde(rename = "stopped")]
55 Stopped,
56}
57
58#[derive(CandidType, Clone, Debug, Deserialize, Serialize)]
63pub struct CanisterSettingsView {
64 pub controllers: Vec<Principal>,
65 pub compute_allocation: Nat,
66 pub memory_allocation: Nat,
67 pub freezing_threshold: Nat,
68 pub reserved_cycles_limit: Nat,
69 pub log_visibility: LogVisibilityView,
70 pub wasm_memory_limit: Nat,
71 pub wasm_memory_threshold: Nat,
72 pub environment_variables: Vec<EnvironmentVariableView>,
73}
74
75#[derive(CandidType, Clone, Debug, Deserialize, Serialize)]
80pub enum LogVisibilityView {
81 #[serde(rename = "controllers")]
82 Controllers,
83 #[serde(rename = "public")]
84 Public,
85 #[serde(rename = "allowed_viewers")]
86 AllowedViewers(Vec<Principal>),
87}
88
89#[derive(CandidType, Clone, Debug, Deserialize, Serialize)]
94pub struct EnvironmentVariableView {
95 pub name: String,
96 pub value: String,
97}
98
99#[derive(CandidType, Clone, Debug, Deserialize, Serialize)]
104pub struct MemoryMetricsView {
105 pub wasm_memory_size: Nat,
106 pub stable_memory_size: Nat,
107 pub global_memory_size: Nat,
108 pub wasm_binary_size: Nat,
109 pub custom_sections_size: Nat,
110 pub canister_history_size: Nat,
111 pub wasm_chunk_store_size: Nat,
112 pub snapshots_size: Nat,
113}
114
115#[derive(CandidType, Clone, Debug, Deserialize, Serialize)]
120pub struct QueryStatsView {
121 pub num_calls_total: Nat,
122 pub num_instructions_total: Nat,
123 pub request_payload_bytes_total: Nat,
124 pub response_payload_bytes_total: Nat,
125}