canic_core/model/memory/
mod.rs1pub mod cycles;
2pub mod directory;
3pub mod env;
4pub mod log;
5pub mod reserve;
6pub mod scaling;
7pub mod sharding;
8pub mod state;
9pub mod topology;
10pub mod types;
11
12pub use canic_memory::MemoryRegistryError;
13pub(crate) use env::Env;
14pub use types::*;
15
16use crate::{
17 Error,
18 model::{ModelError, memory::log::LogError},
19};
20use thiserror::Error as ThisError;
21
22pub(crate) const CANIC_MEMORY_MIN: u8 = 5;
28pub(crate) const CANIC_MEMORY_MAX: u8 = 30;
29
30pub(crate) mod id {
35 pub const ENV_ID: u8 = 5;
39
40 pub mod state {
42 pub const APP_STATE_ID: u8 = 7;
43 pub const SUBNET_STATE_ID: u8 = 8;
44 }
45
46 pub mod directory {
48 pub const APP_DIRECTORY_ID: u8 = 10;
49 pub const SUBNET_DIRECTORY_ID: u8 = 11;
50 }
51
52 pub mod log {
54 pub const LOG_INDEX_ID: u8 = 13;
55 pub const LOG_DATA_ID: u8 = 14;
56 }
57
58 pub mod topology {
60 pub mod app {
61 pub const APP_SUBNET_REGISTRY_ID: u8 = 16;
63 }
64
65 pub mod subnet {
66 pub const SUBNET_CANISTER_REGISTRY_ID: u8 = 17;
68 pub const SUBNET_CANISTER_CHILDREN_ID: u8 = 18;
69 }
70 }
71
72 pub mod root {
75 pub const CANISTER_RESERVE_ID: u8 = 20;
76 }
77
78 pub mod cycles {
80 pub const CYCLE_TRACKER_ID: u8 = 24;
81 }
82
83 pub mod scaling {
85 pub const SCALING_REGISTRY_ID: u8 = 26;
86 }
87
88 pub mod sharding {
90 pub const SHARDING_REGISTRY_ID: u8 = 27;
91 pub const SHARDING_ASSIGNMENT_ID: u8 = 28;
92 }
93}
94
95#[derive(Debug, ThisError)]
100pub enum MemoryError {
101 #[error(transparent)]
103 MemoryRegistryError(#[from] MemoryRegistryError),
104
105 #[error(transparent)]
106 LogError(#[from] LogError),
107}
108
109impl From<MemoryError> for Error {
110 fn from(err: MemoryError) -> Self {
111 ModelError::MemoryError(err).into()
112 }
113}