This is a pluggable engine provider for the waPC RPC exchange protocol. This engine implements WebAssemblyEngineProvider
for the the Bytecode Alliance's wasmtime WebAssembly runtime.
ignore
$ cargo run -p wasmtime-provider --example wasmtime-demo ./wasm/crates/wasm-basic/build/wasm_basic.wasm ping "hi"
```rust use wasmtime_provider::WasmtimeEngineProvider; use wapc::WapcHost; use std::error::Error;
pub fn main() -> Result<(), Box
// Sample host callback that prints the operation a WASM module requested. let host_callback = |id: u64, bd: &str, ns: &str, op: &str, payload: &[u8]| { println!("Guest {} invoked '{}->{}:{}' with a {} byte payload", id, bd, ns, op, payload.len()); // Return success with zero-byte payload. Ok(vec![]) };
let file = "../../wasm/crates/wasm-basic/build/wasmbasic.wasm"; let modulebytes = std::fs::read(file)?;
let engine = WasmtimeEngineProvider::new(&modulebytes, None)?; let host = WapcHost::new(Box::new(engine), Some(Box::new(hostcallback)))?;
let res = host.call("ping", b"payload bytes")?; assert_eq!(res, b"payload bytes");
Ok(()) } ```