1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use serde::{Deserialize, Serialize};
use std::fmt;
#[derive(Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
pub struct Module {
#[serde(with = "serde_bytes")]
code: Vec<u8>,
}
impl Module {
pub fn new(code: Vec<u8>) -> Module {
Module { code }
}
pub fn code(&self) -> &[u8] {
&self.code
}
}
impl fmt::Debug for Module {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Module")
.field("code", &hex::encode(&self.code))
.finish()
}
}