add a non-default constructor of WasmBackend

This commit is contained in:
Valery Antopol 2023-02-08 15:17:07 +03:00
parent 17ca1030a1
commit 81f896f2cf
3 changed files with 14 additions and 1 deletions

View File

@ -49,7 +49,7 @@ pub struct MarineCore<WB: WasmBackend> {
impl<WB: WasmBackend> MarineCore<WB> {
pub fn new() -> Self {
let wasm_backend = WB::default();
let wasm_backend = WB::new();
let store = <WB as WasmBackend>::Store::new(&wasm_backend);
Self {
modules: HashMap::new(),

View File

@ -91,6 +91,17 @@ impl WasmBackend for WasmtimeWasmBackend {
inner: module,
})
}
fn new() -> Self {
let mut config = wasmtime::Config::new();
config
.debug_info(true)
.wasm_backtrace_details(wasmtime::WasmBacktraceDetails::Enable);
let engine = wasmtime::Engine::new(&config).unwrap();
Self {
engine
}
}
}
#[derive(Default)]

View File

@ -57,6 +57,8 @@ pub trait WasmBackend: Clone + Default + 'static {
type Wasi: WasiImplementation<Self>;
fn compile(store: &mut Self::Store, wasm: &[u8]) -> CompilationResult<Self::Module>;
fn new() -> Self;
}
pub struct DelayedContextLifetime<WB: WasmBackend> {