From f7543d3d10fee255a2cd7cbb999191168f55b4aa Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 12 Oct 2021 09:47:12 -0500 Subject: [PATCH] Update docs of `Module::serialize` (#3448) The docs hadn't been updated since `Module::deserialize` was added! --- crates/wasmtime/src/module.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/crates/wasmtime/src/module.rs b/crates/wasmtime/src/module.rs index 3c8da4ac45..4d45669de8 100644 --- a/crates/wasmtime/src/module.rs +++ b/crates/wasmtime/src/module.rs @@ -435,6 +435,10 @@ impl Module { /// [`Module::serialize`] and [`Engine::precompile_module`] back into an /// in-memory [`Module`] that's ready to be instantiated. /// + /// Note that the [`Module::deserialize_file`] method is more optimized than + /// this function, so if the serialized module is already present in a file + /// it's recommended to use that method instead. + /// /// # Unsafety /// /// This function is marked as `unsafe` because if fed invalid input or used @@ -622,10 +626,15 @@ impl Module { sig } - /// Serialize the module to a vector of bytes. + /// Serializes this module to a vector of bytes. /// - /// Use `Module::new` or `Module::from_binary` to create the module - /// from the bytes. + /// This function is similar to the [`Engine::precompile_module`] method + /// where it produces an artifact of Wasmtime which is suitable to later + /// pass into [`Module::deserialize`]. If a module is never instantiated + /// then it's recommended to use [`Engine::precompile_module`] instead of + /// this method, but if a module is both instantiated and serialized then + /// this method can be useful to get the serialized version without + /// compiling twice. #[cfg(compiler)] #[cfg_attr(nightlydoc, doc(cfg(feature = "cranelift")))] // see build.rs pub fn serialize(&self) -> Result> {