Loads a `CodeMemory` from the specified memory region without copying The `expected` marker here is whether the bytes are expected to be a precompiled module or a component. The `memory` provided is expected to be a serialized module (.cwasm) generated by `[Module::serialize]` or [`Engine::precompile_module] or their `Component` counterparts [`Component::serialize`] or `[Engine::precompile_compo
(
&self,
memory: NonNull<[u8]>,
expected: ObjectKind,
)
| 910 | /// of the provided memory. As such, outside writes to this memory region |
| 911 | /// will result in undefined and likely very undesirable behavior. |
| 912 | pub(crate) unsafe fn load_code_raw( |
| 913 | &self, |
| 914 | memory: NonNull<[u8]>, |
| 915 | expected: ObjectKind, |
| 916 | ) -> Result<Arc<crate::CodeMemory>> { |
| 917 | // SAFETY: the contract of this function is the same as that of |
| 918 | // `from_raw`. |
| 919 | unsafe { self.load_code(crate::runtime::vm::MmapVec::from_raw(memory)?, expected) } |
| 920 | } |
| 921 | |
| 922 | /// Like `load_code_bytes`, but creates a mmap from a file on disk. |
| 923 | #[cfg(feature = "std")] |
no test coverage detected