pub(crate) mod ledger;
mod policy;
pub mod registry;
pub mod runtime;
pub use crate::{eager_init, eager_static, ic_memory_key, ic_memory_range};
pub const CANIC_CORE_MEMORY_AUTHORITY: &str = "canic-core";
pub const CANIC_CONTROL_PLANE_MEMORY_AUTHORITY: &str = "canic-control-plane";
#[must_use]
pub fn configured_bucket_pages() -> u16 {
env!("CANIC_MEMORY_BUCKET_PAGES")
.parse()
.expect("build-validated memory bucket size")
}
#[cfg(target_arch = "wasm32")]
pub(crate) fn stable_extent_bytes() -> u64 {
ic_cdk::api::stable_size().saturating_mul(65_536)
}
pub(crate) fn bootstrap_default_memory_manager()
-> Result<(), ic_memory::RuntimeBootstrapError<registry::MemoryRegistryError>> {
let config = ic_memory::MemoryManagerConfig::new(configured_bucket_pages())
.map_err(ic_memory::RuntimeStateError::from)?;
ic_memory::bootstrap_default_memory_manager_with_config(
config,
&policy::CanicMemoryManagerPolicy::new(),
)
.map(|_| ())
}