An open API service indexing awesome lists of open source software.

https://github.com/jsoverson/wasm3-provider

Pluggable wasm3 engine for the waPC Rust host
https://github.com/jsoverson/wasm3-provider

Last synced: 2 months ago
JSON representation

Pluggable wasm3 engine for the waPC Rust host

Awesome Lists containing this project

README

        

# Wasm3 Engine Provider

This is a pluggable engine provider for the [waPC](https://github.com/wapc) RPC exchange protocol. This engine encapsulates
the [wasm3](https://github.com/wasm3) C-based, interpreted WebAssembly runtime.

To run the demo:
```
cargo run --example demo -- ./.assets/hello.wasm test
```

An example of using this engine provider:
```rust
pub fn main() -> Result<(), Box> {
env_logger::init();

let module_bytes = load_file(&std::env::args().skip(1).next().unwrap());
let engine = Wasm3EngineProvider::new(&module_bytes);
let host = WapcHost::new(Box::new(engine), host_callback)?;
let func = std::env::args().skip(2).next().unwrap();

let _res = host.call(&func, b"this is a test")?;
Ok(())
}

fn host_callback(
id: u64,
bd: &str,
ns: &str,
op: &str,
payload: &[u8],
) -> Result, Box> {
println!(
"Guest {} invoked '{}->{}:{}' with payload of {}",
id,
bd,
ns,
op,
::std::str::from_utf8(payload).unwrap()
);
Ok(vec![])
}
```