1use canic_cdk::utils::wasm::get_wasm_hash;
2
3#[derive(Clone, Debug)]
9pub struct WasmModule {
10 bytes: &'static [u8],
11}
12
13impl WasmModule {
14 #[must_use]
15 pub const fn new(bytes: &'static [u8]) -> Self {
16 Self { bytes }
17 }
18
19 #[must_use]
20 pub fn module_hash(&self) -> Vec<u8> {
21 get_wasm_hash(self.bytes)
22 }
23
24 #[must_use]
25 pub fn to_vec(&self) -> Vec<u8> {
26 self.bytes.to_vec()
27 }
28
29 #[must_use]
30 pub const fn bytes(&self) -> &'static [u8] {
31 self.bytes
32 }
33
34 #[must_use]
35 pub const fn len(&self) -> usize {
36 self.bytes.len()
37 }
38
39 #[must_use]
40 pub const fn is_empty(&self) -> bool {
41 self.bytes.is_empty()
42 }
43}