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
- Host: GitHub
- URL: https://github.com/jsoverson/wasm3-provider
- Owner: jsoverson
- License: apache-2.0
- Created: 2021-10-08T14:20:01.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-10-12T07:27:29.000Z (over 3 years ago)
- Last Synced: 2024-12-26T12:23:40.558Z (4 months ago)
- Homepage:
- Size: 884 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
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![])
}
```