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