Skip to main content

canic_host/icp/
model.rs

1use std::path::PathBuf;
2
3use serde::{Deserialize, Serialize};
4
5pub(super) const LOCAL_NETWORK: &str = "local";
6pub const REQUIRED_ICP_CLI_VERSION: &str = "1.0.0";
7pub const ICP_CLI_SUPPORTED_VERSION_RANGE: &str = ">=1.0.0, <2.0.0";
8
9/// Direct local replica endpoint used when ICP project state is unavailable.
10///
11#[derive(Clone, Debug, Eq, PartialEq)]
12pub struct LocalReplicaTarget {
13    pub url: String,
14    pub root_key: String,
15}
16
17///
18/// IcpRawOutput
19///
20
21#[derive(Clone, Debug, Eq, PartialEq)]
22pub struct IcpRawOutput {
23    pub success: bool,
24    pub status: String,
25    pub stdout: Vec<u8>,
26    pub stderr: Vec<u8>,
27}
28
29///
30/// IcpCli
31///
32
33#[derive(Clone, Debug, Eq, PartialEq)]
34pub struct IcpCli {
35    pub(super) executable: String,
36    pub(super) environment: Option<String>,
37    pub(super) network: Option<String>,
38    pub(super) cwd: Option<PathBuf>,
39    pub(super) local_replica: Option<LocalReplicaTarget>,
40}
41
42///
43/// IcpCliVersion
44///
45#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
46pub struct IcpCliVersion {
47    pub major: u64,
48    pub minor: u64,
49    pub patch: u64,
50}
51
52///
53/// IcpSnapshotCreateReceipt
54///
55
56#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
57pub struct IcpSnapshotCreateReceipt {
58    pub snapshot_id: String,
59    pub taken_at_timestamp: Option<u64>,
60    pub total_size_bytes: Option<u64>,
61}
62
63///
64/// IcpCanisterStatusReport
65///
66
67#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
68pub struct IcpCanisterStatusReport {
69    pub id: String,
70    pub name: Option<String>,
71    pub status: String,
72    pub settings: Option<IcpCanisterStatusSettings>,
73    pub module_hash: Option<String>,
74    pub memory_size: Option<String>,
75    pub cycles: Option<String>,
76    pub reserved_cycles: Option<String>,
77    pub idle_cycles_burned_per_day: Option<String>,
78}
79
80///
81/// IcpCanisterStatusSettings
82///
83
84#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
85pub struct IcpCanisterStatusSettings {
86    #[serde(default)]
87    pub controllers: Vec<String>,
88    pub compute_allocation: Option<String>,
89    pub memory_allocation: Option<String>,
90    pub freezing_threshold: Option<String>,
91    pub reserved_cycles_limit: Option<String>,
92    pub wasm_memory_limit: Option<String>,
93    pub wasm_memory_threshold: Option<String>,
94    pub log_memory_limit: Option<String>,
95}