mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-08 05:38:19 +00:00
Added serialize_to_file API
This commit is contained in:
@@ -171,8 +171,8 @@ impl Module {
|
||||
Ok(Self::from_compiled_module(store, compiled))
|
||||
}
|
||||
|
||||
/// Serializes a module into it a propietary serializable format,
|
||||
/// so it can be used later by [`Module::deserialize`].
|
||||
/// Serializes a module into a binary representation that the `Engine`
|
||||
/// can later process via [`Module::deserialize`].
|
||||
///
|
||||
/// # Usage
|
||||
///
|
||||
@@ -189,6 +189,24 @@ impl Module {
|
||||
self.artifact.serialize()
|
||||
}
|
||||
|
||||
/// Serializes a module into a file that the `Engine`
|
||||
/// can later process via [`Module::deserialize_from_file`].
|
||||
///
|
||||
/// # Usage
|
||||
///
|
||||
/// ```ignore
|
||||
/// # use wasmer::*;
|
||||
/// # fn main() -> anyhow::Result<()> {
|
||||
/// # let store = Store::default();
|
||||
/// # let module = Module::from_file(&store, "path/to/foo.wasm")?;
|
||||
/// module.serialize_to_file("path/to/foo.so")?;
|
||||
/// # Ok(())
|
||||
/// # }
|
||||
/// ```
|
||||
pub fn serialize_to_file(&self, path: impl AsRef<Path>) -> Result<(), SerializeError> {
|
||||
self.artifact.serialize_to_file(path.as_ref())
|
||||
}
|
||||
|
||||
/// Deserializes a a serialized Module binary into a `Module`.
|
||||
/// > Note: the module has to be serialized before with the `serialize` method.
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user