(engine: &Engine, file: impl AsRef<Path>)
| 346 | /// state of the file. |
| 347 | #[cfg(all(feature = "std", any(feature = "cranelift", feature = "winch")))] |
| 348 | pub unsafe fn from_trusted_file(engine: &Engine, file: impl AsRef<Path>) -> Result<Module> { |
| 349 | let open_file = open_file_for_mmap(file.as_ref())?; |
| 350 | let mmap = crate::runtime::vm::MmapVec::from_file(open_file)?; |
| 351 | if &mmap[0..4] == b"\x7fELF" { |
| 352 | let code = engine.load_code(mmap, ObjectKind::Module)?; |
| 353 | return Module::from_parts(engine, code, None); |
| 354 | } |
| 355 | |
| 356 | crate::CodeBuilder::new(engine) |
| 357 | .wasm_binary_or_text(&mmap[..], Some(file.as_ref()))? |
| 358 | .compile_module() |
| 359 | } |
| 360 | |
| 361 | /// Deserializes an in-memory compiled module previously created with |
| 362 | /// [`Module::serialize`] or [`Engine::precompile_module`]. |
nothing calls this directly
no test coverage detected