canic_core/dto/
canister.rs1use crate::dto::prelude::*;
2
3#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq)]
8pub struct CanisterInfo {
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)]
21pub struct CanisterStatusResponse {
22 pub status: CanisterStatusType,
23 pub settings: CanisterSettings,
24 pub module_hash: Option<Vec<u8>>,
25 pub memory_size: Nat,
26 pub memory_metrics: MemoryMetrics,
27 pub cycles: Nat,
28 pub reserved_cycles: Nat,
29 pub idle_cycles_burned_per_day: Nat,
30 pub query_stats: QueryStats,
31}
32
33#[derive(CandidType, Clone, Copy, Debug, Deserialize)]
38pub enum CanisterStatusType {
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)]
52pub struct CanisterSettings {
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: LogVisibility,
59 pub log_memory_limit: Nat,
60 pub wasm_memory_limit: Nat,
61 pub wasm_memory_threshold: Nat,
62 pub environment_variables: Vec<EnvironmentVariable>,
63}
64
65#[derive(CandidType, Clone, Debug, Deserialize)]
70pub enum LogVisibility {
71 #[serde(rename = "controllers")]
72 Controllers,
73 #[serde(rename = "public")]
74 Public,
75 #[serde(rename = "allowed_viewers")]
76 AllowedViewers(Vec<Principal>),
77}
78
79#[derive(CandidType, Clone, Debug, Deserialize)]
84pub struct EnvironmentVariable {
85 pub name: String,
86 pub value: String,
87}
88
89#[derive(CandidType, Clone, Debug, Deserialize)]
94pub struct MemoryMetrics {
95 pub wasm_memory_size: Nat,
96 pub stable_memory_size: Nat,
97 pub global_memory_size: Nat,
98 pub wasm_binary_size: Nat,
99 pub custom_sections_size: Nat,
100 pub canister_history_size: Nat,
101 pub wasm_chunk_store_size: Nat,
102 pub snapshots_size: Nat,
103}
104
105#[derive(CandidType, Clone, Debug, Deserialize)]
110pub struct QueryStats {
111 pub num_calls_total: Nat,
112 pub num_instructions_total: Nat,
113 pub request_payload_bytes_total: Nat,
114 pub response_payload_bytes_total: Nat,
115}