3 releases (stable)

1.1.0 Mar 6, 2022
1.0.0 Feb 1, 2022
0.1.0 Jan 2, 2022

#75 in #bus

Download history 19/week @ 2023-12-06 29/week @ 2023-12-13 38/week @ 2023-12-20 19/week @ 2023-12-27 15/week @ 2024-01-03 43/week @ 2024-01-10 23/week @ 2024-01-17 15/week @ 2024-01-24 17/week @ 2024-01-31 31/week @ 2024-02-07 43/week @ 2024-02-14 34/week @ 2024-02-21 65/week @ 2024-02-28 51/week @ 2024-03-06 42/week @ 2024-03-13 44/week @ 2024-03-20

213 downloads per month
Used in 13 crates (via wasm-bus)

MIT/Apache

74KB
1.5K SLoC

WASM Bus Macros

Helpful macros that make it easier to export and import APIs.

Example API

Below is a simple example of how to emit the helper classes and serialization objects for a specific API

use wasm_bus::macros::*;

#[wasm_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 wasm_bus::macros::*;

#[wasm_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>;
}

#[wasm_bus(format = "bincode")]
pub trait WebSocket {
    async fn send(&self, data: Vec<u8>) -> SendResult;
}

Testing

You can test your WASI program by uploading it to wapm.io and then heading over to the Tokera Shell

https://tokera.sh

Dependencies

~1.2–1.7MB
~39K SLoC