#[macro_export]
macro_rules! ic_memory {
($label:path, $id:expr) => {{
const _: () = {
#[ $crate::__reexports::ctor::ctor(unsafe, anonymous, crate_path = $crate::__reexports::ctor) ]
fn __canic_declare_memory_slot() {
$crate::registry::defer_register($id, env!("CARGO_PKG_NAME"), stringify!($label))
.expect("memory id declaration validation failed");
}
};
$crate::runtime::assert_memory_bootstrap_ready(stringify!($label), $id);
let _type_check: Option<$label> = None;
$crate::manager::MEMORY_MANAGER
.with_borrow_mut(|mgr| mgr.get($crate::cdk::structures::memory::MemoryId::new($id)))
}};
}
#[macro_export]
macro_rules! ic_memory_key {
($stable_key:literal, $label:path, $id:expr) => {{
const _: () = {
#[ $crate::__reexports::ctor::ctor(unsafe, anonymous, crate_path = $crate::__reexports::ctor) ]
fn __canic_declare_memory_slot() {
$crate::registry::defer_register_with_key(
$id,
env!("CARGO_PKG_NAME"),
stringify!($label),
$stable_key,
)
.expect("memory id declaration validation failed");
}
};
$crate::runtime::assert_memory_bootstrap_ready(stringify!($label), $id);
let _type_check: Option<$label> = None;
$crate::manager::MEMORY_MANAGER
.with_borrow_mut(|mgr| mgr.get($crate::cdk::structures::memory::MemoryId::new($id)))
}};
}
#[macro_export]
macro_rules! ic_memory_range {
($start:expr, $end:expr) => {{
$crate::registry::defer_reserve_range(env!("CARGO_PKG_NAME"), $start, $end)
.expect("memory range reservation validation failed");
$crate::runtime::registry::MemoryRegistryRuntime::commit_pending_if_initialized()
.expect("late memory range registration commit failed");
}};
}