canic_core/dto/
canister.rs1use crate::dto::prelude::*;
2
3#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
8pub struct CanisterRecordView {
9 pub pid: Principal,
10 pub role: CanisterRole,
11 pub parent_pid: Option<Principal>,
12 pub module_hash: Option<Vec<u8>>,
13 pub created_at: u64,
14}
15
16#[derive(CandidType, Clone, Debug, Deserialize, Serialize)]
21pub struct CanisterStatusView {
22 pub status: CanisterStatusTypeView,
23 pub settings: CanisterSettingsView,
24 pub module_hash: Option<Vec<u8>>,
25 pub memory_size: Nat,
26 pub memory_metrics: MemoryMetricsView,
27 pub cycles: Nat,
28 pub reserved_cycles: Nat,
29 pub idle_cycles_burned_per_day: Nat,
30 pub query_stats: QueryStatsView,
31}
32
33#[derive(CandidType, Clone, Copy, Debug, Deserialize, Serialize)]
38pub enum CanisterStatusTypeView {
39 #[serde(rename = "running")]
40 Running,
41 #[serde(rename = "stopping")]
42 Stopping,
43 #[serde(rename = "stopped")]
44 Stopped,
45}
46
47#[derive(CandidType, Clone, Debug, Deserialize, Serialize)]
52pub struct CanisterSettingsView {
53 pub controllers: Vec<Principal>,
54 pub compute_allocation: Nat,
55 pub memory_allocation: Nat,
56 pub freezing_threshold: Nat,
57 pub reserved_cycles_limit: Nat,
58 pub log_visibility: LogVisibilityView,
59 pub wasm_memory_limit: Nat,
60 pub wasm_memory_threshold: Nat,
61 pub environment_variables: Vec<EnvironmentVariableView>,
62}
63
64#[derive(CandidType, Clone, Debug, Deserialize, Serialize)]
69pub enum LogVisibilityView {
70 #[serde(rename = "controllers")]
71 Controllers,
72 #[serde(rename = "public")]
73 Public,
74 #[serde(rename = "allowed_viewers")]
75 AllowedViewers(Vec<Principal>),
76}
77
78#[derive(CandidType, Clone, Debug, Deserialize, Serialize)]
83pub struct EnvironmentVariableView {
84 pub name: String,
85 pub value: String,
86}
87
88#[derive(CandidType, Clone, Debug, Deserialize, Serialize)]
93pub struct MemoryMetricsView {
94 pub wasm_memory_size: Nat,
95 pub stable_memory_size: Nat,
96 pub global_memory_size: Nat,
97 pub wasm_binary_size: Nat,
98 pub custom_sections_size: Nat,
99 pub canister_history_size: Nat,
100 pub wasm_chunk_store_size: Nat,
101 pub snapshots_size: Nat,
102}
103
104#[derive(CandidType, Clone, Debug, Deserialize, Serialize)]
109pub struct QueryStatsView {
110 pub num_calls_total: Nat,
111 pub num_instructions_total: Nat,
112 pub request_payload_bytes_total: Nat,
113 pub response_payload_bytes_total: Nat,
114}