#sdk #wapc #webassembly #wasm #wasm3

wasm3-provider

A wasm3 engine provider for the waPC host

2 releases

0.0.2 Oct 27, 2020
0.0.1 Sep 23, 2020

#424 in WebAssembly

Download history 3/week @ 2020-12-24 35/week @ 2020-12-31 66/week @ 2021-01-07 36/week @ 2021-01-14 61/week @ 2021-01-21 51/week @ 2021-01-28 138/week @ 2021-02-04 143/week @ 2021-02-11 66/week @ 2021-02-18 109/week @ 2021-02-25 63/week @ 2021-03-04 67/week @ 2021-03-11 123/week @ 2021-03-18 100/week @ 2021-03-25 65/week @ 2021-04-01 113/week @ 2021-04-08

275 downloads per month
Used in 3 crates (2 directly)

Apache-2.0

13KB
251 lines

Wasm3 Engine Provider

This is a pluggable engine provider for the waPC RPC exchange protocol. This engine encapsulates the 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:

pub fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
    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<Vec<u8>, Box<dyn std::error::Error + Send + Sync>> {
    println!(
        "Guest {} invoked '{}->{}:{}' with payload of {}",
        id,
        bd,
        ns,
        op,
        ::std::str::from_utf8(payload).unwrap()
    );
    Ok(vec![])
}

Dependencies

~2.6–4MB
~94K SLoC