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