1use crate::{
2 Error, ids::CanisterRole, log, log::Topic, model::wasm::WasmRegistry, types::WasmModule,
3};
4
5pub struct WasmOps;
11
12impl WasmOps {
13 #[must_use]
15 pub fn get(role: &CanisterRole) -> Option<WasmModule> {
16 WasmRegistry::get(role)
17 }
18
19 pub fn try_get(role: &CanisterRole) -> Result<WasmModule, Error> {
21 WasmRegistry::try_get(role)
22 }
23
24 #[allow(clippy::cast_precision_loss)]
26 pub fn import_static(wasms: &'static [(CanisterRole, &[u8])]) {
27 for (role, bytes) in wasms {
28 let wasm = WasmModule::new(bytes);
29 let wasm_size = wasm.len();
30
31 WasmRegistry::insert(role, wasm);
32
33 log!(
34 Topic::Wasm,
35 Info,
36 "📄 registry.insert: {} ({:.2} KB)",
37 role,
38 wasm_size as f64 / 1000.0
39 );
40 }
41 }
42}