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 ::ctor;
65}
66
67pub const CRATE_NAME: &str = env!("CARGO_PKG_NAME");
72pub const VERSION: &str = env!("CARGO_PKG_VERSION");
73pub const CANIC_MEMORY_MIN: u8 = storage::stable::CANIC_MEMORY_MIN;
74pub const CANIC_MEMORY_MAX: u8 = storage::stable::CANIC_MEMORY_MAX;
75pub const CANIC_WASM_CHUNK_BYTES: usize = 1_048_576;
78
79#[cfg(test)]
80const _: () = {
81 fn __canic_memory_test_bootstrap() {
82 crate::api::runtime::MemoryRuntimeApi::bootstrap_registry()
83 .expect("test stable-memory bootstrap");
84 }
85
86 #[crate::__reexports::ctor::ctor(
87 unsafe,
88 anonymous,
89 crate_path = crate::__reexports::ctor
90 )]
91 fn __canic_install_memory_test_bootstrap_hook() {
92 crate::memory::runtime::install_test_bootstrap_hook(__canic_memory_test_bootstrap);
93 }
94};
95
96#[macro_export]
97macro_rules! perf {
98 ($($label:tt)*) => {{
99 $crate::perf::PERF_LAST.with(|last| {
100 let now = $crate::perf::perf_counter();
101 let then = *last.borrow();
102 let delta = now.saturating_sub(then);
103
104 *last.borrow_mut() = now;
105
106 let label = format!($($label)*);
107 $crate::perf::record_checkpoint(module_path!(), &label, delta);
108 });
109 }};
110}
111
112#[cfg(test)]
113#[macro_export]
114macro_rules! assert_err_variant {
115 ($err:expr, $pat:pat $(if $guard:expr)? $(,)?) => {{
116 match $err {
117 $pat $(if $guard)? => {}
118 other => panic!("unexpected error variant: {other:?}"),
119 }
120 }};
121}
122
123#[cfg(test)]
124mod memory_bootstrap_tests {
125 #[test]
126 fn installs_host_test_bootstrap_hook() {
127 assert!(crate::memory::runtime::has_test_bootstrap_hook());
128 }
129}