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