Serialize and deserialize compilation artifacts. (#2020)

* Serialize and deserialize Module
* Use bincode to serialize
* Add wasm_module_serialize; docs
* Simple tests
This commit is contained in:
Yury Delendik
2020-07-21 15:05:50 -05:00
committed by GitHub
parent c420f65214
commit 399ee0a54c
17 changed files with 528 additions and 20 deletions

View File

@@ -45,7 +45,7 @@ pub trait Configurable {
}
/// Collect settings values based on a template.
#[derive(Clone)]
#[derive(Clone, Hash)]
pub struct Builder {
template: &'static detail::Template,
bytes: Box<[u8]>,
@@ -212,8 +212,10 @@ impl<'a> PredicateView<'a> {
pub mod detail {
use crate::constant_hash;
use core::fmt;
use core::hash::Hash;
/// An instruction group template.
#[derive(Hash)]
pub struct Template {
/// Name of the instruction group.
pub name: &'static str,
@@ -281,6 +283,7 @@ pub mod detail {
/// A setting descriptor holds the information needed to generically set and print a setting.
///
/// Each settings group will be represented as a constant DESCRIPTORS array.
#[derive(Hash)]
pub struct Descriptor {
/// Lower snake-case name of setting as defined in meta.
pub name: &'static str,
@@ -293,7 +296,7 @@ pub mod detail {
}
/// The different kind of settings along with descriptor bits that depend on the kind.
#[derive(Clone, Copy)]
#[derive(Clone, Copy, Hash)]
pub enum Detail {
/// A boolean setting only uses one bit, numbered from LSB.
Bool {