Check that the module exports an initialization function, and that the function has the correct type.
(&self, module: &wasmtime::Module)
| 29 | /// Check that the module exports an initialization function, and that the |
| 30 | /// function has the correct type. |
| 31 | fn validate_init_func(&self, module: &wasmtime::Module) -> wasmtime::Result<()> { |
| 32 | log::debug!("Validating the exported initialization function"); |
| 33 | match module.get_export(self.get_init_func()) { |
| 34 | Some(wasmtime::ExternType::Func(func_ty)) => { |
| 35 | if func_ty.params().len() != 0 || func_ty.results().len() != 0 { |
| 36 | wasmtime::bail!( |
| 37 | "the Wasm module's `{}` function export does not have type `[] -> []`", |
| 38 | self.get_init_func() |
| 39 | ); |
| 40 | } |
| 41 | } |
| 42 | Some(_) => wasmtime::bail!( |
| 43 | "the Wasm module's `{}` export is not a function", |
| 44 | self.get_init_func() |
| 45 | ), |
| 46 | None => wasmtime::bail!( |
| 47 | "the Wasm module does not have a `{}` export", |
| 48 | self.get_init_func() |
| 49 | ), |
| 50 | } |
| 51 | Ok(()) |
| 52 | } |
| 53 | |
| 54 | /// Instantiate the module and call its initialization function. |
| 55 | async fn initialize<T: Send>( |
no test coverage detected