Skip to main content

canic_host/icp/
model.rs

1use std::path::PathBuf;
2
3use serde::{Deserialize, Serialize};
4
5pub(super) const LOCAL_ICP_TARGET: &str = "local";
6pub(super) const REQUIRED_ICP_CLI_VERSION: &str = "1.2.0";
7pub(super) const ICP_CLI_SUPPORTED_VERSION_RANGE: &str = ">=1.2.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) cwd: Option<PathBuf>,
38    pub(super) local_replica: Option<LocalReplicaTarget>,
39    pub(super) inherited_fd: Option<i32>,
40    pub(super) identity_password_file: Option<PathBuf>,
41}
42
43///
44/// IcpCliVersion
45///
46#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
47pub(super) struct IcpCliVersion {
48    pub(super) major: u64,
49    pub(super) minor: u64,
50    pub(super) patch: u64,
51}
52
53///
54/// IcpSnapshot
55///
56
57#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
58pub struct IcpSnapshot {
59    pub snapshot_id: String,
60    pub taken_at_timestamp: Option<u64>,
61    pub total_size_bytes: Option<u64>,
62}
63
64///
65/// IcpCanisterStatusReport
66///
67
68#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
69pub struct IcpCanisterStatusReport {
70    pub id: String,
71    pub name: Option<String>,
72    pub status: String,
73    pub settings: Option<IcpCanisterStatusSettings>,
74    pub module_hash: Option<String>,
75    pub memory_size: Option<String>,
76    pub cycles: Option<String>,
77    pub reserved_cycles: Option<String>,
78    pub idle_cycles_burned_per_day: Option<String>,
79}
80
81///
82/// IcpCanisterStatusSettings
83///
84
85#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
86pub struct IcpCanisterStatusSettings {
87    #[serde(default)]
88    pub controllers: Vec<String>,
89    pub compute_allocation: Option<String>,
90    pub memory_allocation: Option<String>,
91    pub freezing_threshold: Option<String>,
92    pub reserved_cycles_limit: Option<String>,
93    pub wasm_memory_limit: Option<String>,
94    pub wasm_memory_threshold: Option<String>,
95    pub log_memory_limit: Option<String>,
96}