#wasm-module #wapc #sdk #waxosuit

wapc-guest

Guest SDK for building waPC-compliant WebAssembly Modules

12 releases (4 stable)

1.2.0 Nov 26, 2024
1.1.0 Mar 23, 2023
1.0.2 Jan 17, 2023
1.0.0 Feb 10, 2022
0.1.1 Sep 19, 2019

#279 in WebAssembly

Download history 801/week @ 2024-12-01 1859/week @ 2024-12-08 2080/week @ 2024-12-15 1933/week @ 2024-12-22 2511/week @ 2024-12-29 1495/week @ 2025-01-05 2084/week @ 2025-01-12 2398/week @ 2025-01-19 1847/week @ 2025-01-26 1993/week @ 2025-02-02 2698/week @ 2025-02-09 1830/week @ 2025-02-16 1866/week @ 2025-02-23 2662/week @ 2025-03-02 3172/week @ 2025-03-09 3634/week @ 2025-03-16

11,466 downloads per month
Used in 22 crates (18 directly)

Apache-2.0

12KB
230 lines

waPC Guest SDK

crates.io license

The wapc-guest library is an implementation of the guest-side of the waPC WebAssembly protocol. wapc-guest gives Rust developers the pieces necessary to easily compile WebAssembly modules that you can load in waPC hosts. Each guest module registers function handlers with [register_function()]. Each handler should return a [CallResult] (a Result<Vec<u8>,Box<dyn Error + Sync + Send>>) with the function's return value.

It's typically used by code generated by the wapc CLI.

Example

use wapc_guest as wapc;

#[no_mangle]
pub fn wapc_init() {
  wapc::register_function("ping", ping);
}

fn ping(msg: &[u8]) -> wapc::CallResult {
  wapc::console_log(&format!(
    "IN_WASM: Received request for `ping` operation with payload : {}",
    std::str::from_utf8(msg).unwrap()
  ));
  let _res = wapc::host_call("binding", "sample:namespace", "pong", msg)?;
  Ok(msg.to_vec())
}

Building

This crate is meant for projects targeting wasm32-unknown-unknown or wasm32-wasip1.

Dependencies

~0.4–5MB
~14K SLoC