Skip to main content

canic_core/api/runtime/
mod.rs

1pub mod install;
2
3use crate::{
4    CRATE_NAME,
5    dto::error::Error,
6    memory::runtime::MemoryRuntimeApi as MemoryBootstrapApi,
7    ops::runtime::memory::MemoryRegistryOpsError,
8    storage::stable::{CANIC_MEMORY_MAX, CANIC_MEMORY_MIN},
9};
10
11///
12/// MemoryRuntimeApi
13///
14
15pub struct MemoryRuntimeApi;
16
17impl MemoryRuntimeApi {
18    /// Bootstrap Canic's reserved stable-memory range and flush deferred registrations.
19    pub fn bootstrap_registry() -> Result<(), Error> {
20        let _ =
21            MemoryBootstrapApi::bootstrap_registry(CRATE_NAME, CANIC_MEMORY_MIN, CANIC_MEMORY_MAX)
22                .map_err(MemoryRegistryOpsError::from)
23                .map_err(crate::InternalError::from)
24                .map_err(Error::from)?;
25
26        Ok(())
27    }
28}