Crates.io | wasmer-bus |
lib.rs | wasmer-bus |
version | 1.1.0 |
source | src |
created_at | 2022-08-08 01:34:54.21567 |
updated_at | 2022-08-08 01:34:54.21567 |
description | Invocation bus for web assembly modules |
homepage | |
repository | https://github.com/john-sharratt/ate |
max_upload_size | |
id | 640498 |
size | 67,049 |
The WASM Genernal Purpose Bus implements a standard syscall interface for WebAssembly libraries and executables to use to invoke and receive calls between WASM modules and/or operating system functions.
Currently the WASM Bus is supported by the following runtimes:
Functionality supported by this BUS includes
In order to implment this BUS on your runtime one needs to chain to the ABI exposed in this library and implement the functions.
For a reference implementation see below:
https://github.com/wasmerio/ate/tree/master/wasmer_term/src/bus
Below is a simple example of how to emit the helper classes and serialization objects for a specific API
use wasmer_bus::macros::*;
#[wasmer_bus(format = "json")]
pub trait Time {
async fn sleep(&self, duration_ms: u128);
}
It is also possible to emit a series of sub-apis that carry with them some specific context
use serde::*;
use std::sync::Arc;
use wasmer_bus::macros::*;
#[wasmer_bus(format = "bincode")]
pub trait SocketBuilder {
async fn connect(
&self,
url: String,
state_change: impl Fn(SocketState),
receive: impl Fn(Vec<u8>),
) -> Arc<dyn WebSocket>;
}
#[wasmer_bus(format = "bincode")]
pub trait WebSocket {
async fn send(&self, data: Vec<u8>) -> SendResult;
}
You can test your WASI program by uploading it to wapm.io and then heading over to the Wasmer Shell