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#[cfg(test)]
48pub mod test;
49
50pub(crate) mod config;
51pub(crate) mod domain;
52pub(crate) mod infra;
53pub(crate) mod lifecycle;
54pub(crate) mod model;
55pub(crate) mod ops;
56pub(crate) mod storage;
57pub(crate) mod view;
58pub(crate) mod workflow;
59
60pub(crate) use error::{InternalError, InternalErrorClass, InternalErrorOrigin};
61
62#[doc(hidden)]
65pub mod __reexports {
66 pub use ::ic_memory;
67 pub use ::ic_memory::__reexports::ctor;
68}
69
70pub const CRATE_NAME: &str = env!("CARGO_PKG_NAME");
75pub const VERSION: &str = env!("CARGO_PKG_VERSION");
76pub const CANIC_MEMORY_MIN: u8 = storage::stable::CANIC_MEMORY_MIN;
77pub const CANIC_MEMORY_MAX: u8 = storage::stable::CANIC_MEMORY_MAX;
78pub const CANIC_WASM_CHUNK_BYTES: usize = 1_048_576;
81
82ic_memory::ic_memory_range!(
83 start = storage::stable::CANIC_MEMORY_MIN,
84 end = storage::stable::CANIC_MEMORY_MAX,
85);
86
87#[cfg(test)]
88const _: () = {
89 fn __canic_memory_test_bootstrap() {
90 crate::api::runtime::MemoryRuntimeApi::bootstrap_registry()
91 .expect("test stable-memory bootstrap");
92 }
93
94 #[crate::__reexports::ctor::ctor(
95 unsafe,
96 anonymous,
97 crate_path = crate::__reexports::ctor
98 )]
99 fn __canic_install_memory_test_bootstrap_hook() {
100 crate::memory::runtime::install_test_bootstrap_hook(__canic_memory_test_bootstrap);
101 }
102};
103
104#[macro_export]
105macro_rules! perf {
106 ($($label:tt)*) => {{
107 $crate::perf::PERF_LAST.with(|last| {
108 let now = $crate::perf::perf_counter();
109 let then = *last.borrow();
110 let delta = now.saturating_sub(then);
111
112 *last.borrow_mut() = now;
113
114 let label = format!($($label)*);
115 $crate::perf::record_checkpoint(module_path!(), &label, delta);
116 });
117 }};
118}
119
120#[cfg(test)]
121#[macro_export]
122macro_rules! assert_err_variant {
123 ($err:expr, $pat:pat $(if $guard:expr)? $(,)?) => {{
124 match $err {
125 $pat $(if $guard)? => {}
126 other => panic!("unexpected error variant: {other:?}"),
127 }
128 }};
129}
130
131#[cfg(test)]
132mod memory_bootstrap_tests {
133 #[test]
134 fn installs_host_test_bootstrap_hook() {
135 assert!(crate::memory::runtime::has_test_bootstrap_hook());
136 }
137}