1#[doc(hidden)]
24pub mod access;
25pub mod api;
26#[doc(hidden)]
27pub mod bootstrap;
28#[doc(hidden)]
29pub mod cdk;
30#[doc(hidden)]
31pub mod control_plane_support;
32pub mod diagnostics;
33#[doc(hidden)]
34pub mod dispatch;
35pub mod dto;
36#[doc(hidden)]
37mod error;
38mod format;
39pub mod ids;
40#[doc(hidden)]
41pub mod ingress;
42pub mod log;
43pub mod memory;
44mod memory_macros;
45pub mod perf;
46pub mod protocol;
47pub mod replay_policy;
48#[doc(hidden)]
49pub mod role_contract;
50#[doc(hidden)]
51pub mod shared_support;
52#[doc(hidden)]
53pub mod state_contract;
54#[cfg(test)]
55pub mod test;
56
57pub(crate) mod config;
58pub(crate) mod domain;
59pub(crate) mod infra;
60pub(crate) mod lifecycle;
61pub(crate) mod model;
62pub(crate) mod ops;
63pub(crate) mod storage;
64pub(crate) mod view;
65pub(crate) mod workflow;
66
67pub(crate) use error::InternalError;
68
69#[doc(hidden)]
72pub mod __reexports {
73 pub use ::ic_memory;
74 pub use ::ic_memory::__reexports::ctor;
75}
76
77pub const VERSION: &str = env!("CARGO_PKG_VERSION");
82pub const CANIC_WASM_CHUNK_BYTES: usize = 1_048_576;
85pub const CANIC_WASM_CHUNK_REQUEST_MAX_BYTES: usize = CANIC_WASM_CHUNK_BYTES + 64 * 1024;
87
88crate::ic_memory_range!(
89 authority = CANIC_CORE_MEMORY_AUTHORITY,
90 start = role_contract::allocation::CANIC_CORE_MIN_ID,
91 end = role_contract::allocation::CANIC_CORE_LOWER_MAX_ID,
92);
93crate::ic_memory_range!(
94 authority = CANIC_CORE_MEMORY_AUTHORITY,
95 start = role_contract::allocation::CANIC_CORE_UPPER_MIN_ID,
96 end = role_contract::allocation::CANIC_CORE_MAX_ID,
97);
98ic_memory_range!(
99 authority = CANIC_CORE_MEMORY_AUTHORITY,
100 start = role_contract::allocation::CANIC_CORE_AUTH_MIN_ID,
101 end = role_contract::allocation::CANIC_CORE_AUTH_MAX_ID,
102);
103
104#[cfg(test)]
105const _: () = {
106 fn __canic_memory_test_bootstrap() {
107 crate::api::runtime::MemoryRuntimeApi::bootstrap_registry()
108 .expect("test stable-memory bootstrap");
109 }
110
111 #[crate::__reexports::ctor::ctor(
112 unsafe,
113 anonymous,
114 crate_path = crate::__reexports::ctor
115 )]
116 fn __canic_install_memory_test_bootstrap_hook() {
117 crate::memory::runtime::install_test_bootstrap_hook(__canic_memory_test_bootstrap);
118 }
119};
120
121#[macro_export]
122macro_rules! perf {
123 ($($label:tt)*) => {{
124 $crate::perf::PERF_LAST.with(|last| {
125 let now = $crate::perf::perf_counter();
126 let then = *last.borrow();
127 let delta = now.saturating_sub(then);
128
129 *last.borrow_mut() = now;
130
131 let label = format!($($label)*);
132 $crate::perf::record_checkpoint(module_path!(), &label, delta);
133 });
134 }};
135}
136
137#[cfg(test)]
138#[macro_export]
139macro_rules! assert_err_variant {
140 ($err:expr, $pat:pat $(if $guard:expr)? $(,)?) => {{
141 match $err {
142 $pat $(if $guard)? => {}
143 other => panic!("unexpected error variant: {other:?}"),
144 }
145 }};
146}
147
148#[cfg(test)]
149mod memory_bootstrap_tests {
150 #[test]
151 fn installs_host_test_bootstrap_hook() {
152 assert!(crate::memory::runtime::has_test_bootstrap_hook());
153 }
154}