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/// IcpSnapshotUploadReceipt
65///
66
67#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
68pub struct IcpSnapshotUploadReceipt {
69    pub snapshot_id: String,
70}
71
72///
73/// IcpCanisterStatusReport
74///
75
76#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
77pub struct IcpCanisterStatusReport {
78    pub id: String,
79    pub name: Option<String>,
80    pub status: String,
81    pub settings: Option<IcpCanisterStatusSettings>,
82    pub module_hash: Option<String>,
83    pub memory_size: Option<String>,
84    pub cycles: Option<String>,
85    pub reserved_cycles: Option<String>,
86    pub idle_cycles_burned_per_day: Option<String>,
87}
88
89///
90/// IcpCanisterStatusSettings
91///
92
93#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
94pub struct IcpCanisterStatusSettings {
95    #[serde(default)]
96    pub controllers: Vec<String>,
97    pub compute_allocation: Option<String>,
98    pub memory_allocation: Option<String>,
99    pub freezing_threshold: Option<String>,
100    pub reserved_cycles_limit: Option<String>,
101    pub wasm_memory_limit: Option<String>,
102    pub wasm_memory_threshold: Option<String>,
103    pub log_memory_limit: Option<String>,
104}