diem_types/transaction/
module.rs

1// Copyright (c) The Diem Core Contributors
2// SPDX-License-Identifier: Apache-2.0
3
4// Copyright 2021 Conflux Foundation. All rights reserved.
5// Conflux is free software and distributed under GNU General Public License.
6// See http://www.gnu.org/licenses/
7
8use serde::{Deserialize, Serialize};
9use std::fmt;
10
11#[derive(Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
12pub struct Module {
13    #[serde(with = "serde_bytes")]
14    code: Vec<u8>,
15}
16
17impl Module {
18    pub fn new(code: Vec<u8>) -> Module { Module { code } }
19
20    pub fn code(&self) -> &[u8] { &self.code }
21}
22
23impl fmt::Debug for Module {
24    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
25        f.debug_struct("Module")
26            .field("code", &hex::encode(&self.code))
27            .finish()
28    }
29}