use crate::wasm_config_t;
use wasmtime::Engine;
#[repr(C)]
#[derive(Clone)]
pub struct wasm_engine_t {
pub(crate) engine: Engine,
}
wasmtime_c_api_macros::declare_own!(wasm_engine_t);
#[no_mangle]
pub extern "C" fn wasm_engine_new() -> Box<wasm_engine_t> {
#[cfg(feature = "logging")]
drop(env_logger::try_init());
Box::new(wasm_engine_t {
engine: Engine::default(),
})
}
#[no_mangle]
pub extern "C" fn wasm_engine_new_with_config(c: Box<wasm_config_t>) -> Box<wasm_engine_t> {
#[cfg(feature = "logging")]
drop(env_logger::try_init());
let config = c.config;
Box::new(wasm_engine_t {
engine: Engine::new(&config).unwrap(),
})
}
#[no_mangle]
pub extern "C" fn wasmtime_engine_clone(engine: &wasm_engine_t) -> Box<wasm_engine_t> {
Box::new(engine.clone())
}
#[no_mangle]
pub extern "C" fn wasmtime_engine_increment_epoch(engine: &wasm_engine_t) {
engine.engine.increment_epoch();
}