Fix f64 -> RawValue in JS API

This commit is contained in:
Felix Schütt
2022-08-23 12:59:21 +02:00
parent fd80f77bb6
commit b1fac30b3c
2 changed files with 34 additions and 5 deletions

View File

@@ -318,6 +318,33 @@ impl Module {
Self::new(_store, bytes).map_err(|e| DeserializeError::Compiler(e))
}
#[cfg(feature = "compiler")]
/// Deserializes a a serialized Module located in a `Path` into a `Module`.
/// > Note: the module has to be serialized before with the `serialize` method.
///
/// # Safety
///
/// Please check [`Module::deserialize`].
///
/// # Usage
///
/// ```ignore
/// # use wasmer::*;
/// # let mut store = Store::default();
/// # fn main() -> anyhow::Result<()> {
/// let module = Module::deserialize_from_file(&store, path)?;
/// # Ok(())
/// # }
/// ```
pub unsafe fn deserialize_from_file(
store: &impl AsStoreRef,
path: impl AsRef<Path>,
) -> Result<Self, DeserializeError> {
let artifact = std::fs::read(path.as_ref())?;
Ok(Self::new(store, bytes).map_err(|e| DeserializeError::Compiler(e)))
}
/// Sets the name of the current module.
/// This is normally useful for stacktraces and debugging.
///