MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / serialize

Method serialize

crates/wasmtime/src/runtime/module.rs:620–642  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

618 /// compiling twice.
619 #[cfg(any(feature = "cranelift", feature = "winch"))]
620 pub fn serialize(&self) -> Result<Vec<u8>> {
621 // The current representation of compiled modules within a compiled
622 // component means that it cannot be serialized. The mmap returned here
623 // is the mmap for the entire component and while it contains all
624 // necessary data to deserialize this particular module it's all
625 // embedded within component-specific information.
626 //
627 // It's not the hardest thing in the world to support this but it's
628 // expected that there's not much of a use case at this time. In theory
629 // all that needs to be done is to edit the `.wasmtime.info` section
630 // to contains this module's metadata instead of the metadata for the
631 // whole component. The metadata itself is fairly trivially
632 // recreateable here it's more that there's no easy one-off API for
633 // editing the sections of an ELF object to use here.
634 //
635 // Overall for now this simply always returns an error in this
636 // situation. If you're reading this and feel that the situation should
637 // be different please feel free to open an issue.
638 if !self.inner.serializable {
639 bail!("cannot serialize a module exported from a component");
640 }
641 Ok(self.engine_code().image().to_vec())
642 }
643
644 pub(crate) fn compiled_module(&self) -> &CompiledModule {
645 &self.inner.module

Calls 4

OkFunction · 0.85
to_vecMethod · 0.45
imageMethod · 0.45
engine_codeMethod · 0.45