#wasi #wasm #bus


Invocation bus for web assembly modules

1 stable release

1.1.0 Aug 8, 2022

#137 in Database implementations

Download history 29/week @ 2023-08-09 32/week @ 2023-08-16 19/week @ 2023-08-23 24/week @ 2023-08-30 35/week @ 2023-09-06 29/week @ 2023-09-13 20/week @ 2023-09-20 36/week @ 2023-09-27 22/week @ 2023-10-04 27/week @ 2023-10-11 28/week @ 2023-10-18 32/week @ 2023-10-25 30/week @ 2023-11-01 36/week @ 2023-11-08 46/week @ 2023-11-15 38/week @ 2023-11-22

155 downloads per month
Used in 12 crates (6 directly)


2.5K SLoC

WASM General Purpose Bus

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

  • Web Socket connections
  • HTTP and HTTPS calls
  • Spawning sub-processes
  • Thread sleeping and timeouts
  • Asynchronous Runtime Engine
  • Client side invocation of WASM modules


  • Spawning threads
  • Multi-threaded Runtime Engine
  • Universal Logging
  • Server side invocation of WASM modules

Backend Implementations

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:


Example API

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);

Relative Objects

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(
        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



~99K SLoC