canic_core/ops/
wasm.rs

1use crate::{Error, ids::CanisterRole, model::wasm::WasmRegistry, types::WasmModule};
2
3///
4/// WasmOps
5/// Thin ops-layer wrapper around the embedded WasmRegistry.
6///
7
8pub struct WasmOps;
9
10impl WasmOps {
11    /// Fetch a WASM module for the given canister type if registered.
12    #[must_use]
13    pub fn get(role: &CanisterRole) -> Option<WasmModule> {
14        WasmRegistry::get(role)
15    }
16
17    /// Fetch a WASM module or return an error when missing.
18    pub fn try_get(role: &CanisterRole) -> Result<WasmModule, Error> {
19        WasmRegistry::try_get(role)
20    }
21
22    /// Import a static slice of (role, wasm bytes) at startup.
23    pub fn import_static(wasms: &'static [(CanisterRole, &[u8])]) {
24        WasmRegistry::import(wasms);
25    }
26}