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