7 releases

0.0.7 Oct 25, 2021
0.0.6 Oct 25, 2021
0.0.4 Aug 4, 2021
0.0.3 Apr 18, 2021
0.0.1 Sep 23, 2020

#65 in WebAssembly

Download history 110/week @ 2021-10-01 105/week @ 2021-10-08 238/week @ 2021-10-15 256/week @ 2021-10-22 48/week @ 2021-10-29 63/week @ 2021-11-05 326/week @ 2021-11-12 388/week @ 2021-11-19 198/week @ 2021-11-26 67/week @ 2021-12-03 65/week @ 2021-12-10 290/week @ 2021-12-17 102/week @ 2021-12-24 42/week @ 2021-12-31 137/week @ 2022-01-07 1580/week @ 2022-01-14

1,906 downloads per month
Used in 3 crates (2 directly)

Apache-2.0

23KB
474 lines

Wasmtime Engine Provider

This is a pluggable engine provider for the waPC RPC exchange protocol. This engine encapsulates the Bytecode Alliance wasmtime 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 = WasmtimeEngineProvider::new(&module_bytes, None);
    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

~10–14MB
~306K SLoC

va