refactor(wasmer): apply fmt

This commit is contained in:
OJ Kwon
2022-03-18 14:33:23 -07:00
parent 8db42b61f4
commit 5de43d557e
2 changed files with 8 additions and 6 deletions

View File

@@ -123,4 +123,4 @@ pub enum DeserializeError {
/// trying to allocate the required resources. /// trying to allocate the required resources.
#[cfg_attr(feature = "std", error(transparent))] #[cfg_attr(feature = "std", error(transparent))]
Compiler(CompileError), Compiler(CompileError),
} }

View File

@@ -3,9 +3,9 @@ use crate::js::resolver::Resolver;
use crate::js::store::Store; use crate::js::store::Store;
use crate::js::types::{ExportType, ImportType}; use crate::js::types::{ExportType, ImportType};
// use crate::js::InstantiationError; // use crate::js::InstantiationError;
use crate::js::error::{CompileError, SerializeError, DeserializeError};
#[cfg(feature = "wat")] #[cfg(feature = "wat")]
use crate::js::error::WasmError; use crate::js::error::WasmError;
use crate::js::error::{CompileError, DeserializeError, SerializeError};
use crate::js::RuntimeError; use crate::js::RuntimeError;
use js_sys::{Reflect, Uint8Array, WebAssembly}; use js_sys::{Reflect, Uint8Array, WebAssembly};
use std::fmt; use std::fmt;
@@ -63,7 +63,7 @@ pub struct Module {
// WebAssembly type hints // WebAssembly type hints
type_hints: Option<ModuleTypeHints>, type_hints: Option<ModuleTypeHints>,
#[cfg(feature = "js-serializable-module")] #[cfg(feature = "js-serializable-module")]
raw_bytes: Option<Vec<u8>> raw_bytes: Option<Vec<u8>>,
} }
impl Module { impl Module {
@@ -197,7 +197,7 @@ impl Module {
type_hints, type_hints,
name, name,
#[cfg(feature = "js-serializable-module")] #[cfg(feature = "js-serializable-module")]
raw_bytes: Some(binary.to_vec()) raw_bytes: Some(binary.to_vec()),
}) })
} }
@@ -282,7 +282,9 @@ impl Module {
/// ///
#[cfg(feature = "js-serializable-module")] #[cfg(feature = "js-serializable-module")]
pub fn serialize(&self) -> Result<Vec<u8>, SerializeError> { pub fn serialize(&self) -> Result<Vec<u8>, SerializeError> {
self.raw_bytes.clone().ok_or(SerializeError::Generic("Not able to serialize module".to_string())) self.raw_bytes.clone().ok_or(SerializeError::Generic(
"Not able to serialize module".to_string(),
))
} }
/// Deserializes a serialized Module binary into a `Module`. /// Deserializes a serialized Module binary into a `Module`.
@@ -534,7 +536,7 @@ impl From<WebAssembly::Module> for Module {
name: None, name: None,
type_hints: None, type_hints: None,
#[cfg(feature = "js-serializable-module")] #[cfg(feature = "js-serializable-module")]
raw_bytes: None raw_bytes: None,
} }
} }
} }