Crate waxosuit_guest

Crate waxosuit_guest 

Source
Expand description

§waxosuit-guest

The waxosuit-guest library provides WebAssembly module developers with access to the Waxosuit host runtime. Each guest module has a single call handler, declared with the call_handler! macro. Inside this call handler, the guest module should check the operation of the delivered message and handle it accordingly, returning any binary payload in response. It is the responsibility of the guest module to ensure that the capability provider will be able to understand whichever messages it sends.

§Example

extern crate waxosuit_guest as guest;

use guest::prelude::*;

call_handler!(handle_call);

pub fn handle_call(ctx: &CapabilitiesContext, operation: &str, msg: &[u8]) -> CallResult {
    match operation {
        http::OP_HANDLE_REQUEST => hello_world(ctx, msg),
        core::OP_HEALTH_REQUEST => Ok(vec![]),
        _ => Err("bad dispatch".into()),
    }     
}

fn hello_world(
   _ctx: &CapabilitiesContext,
   _msg: &[u8]) -> CallResult {
    Ok(vec![])
}

Re-exports§

pub extern crate prost;
pub extern crate wapc_guest as wapc;

Modules§

kv
Key-Value Store
msg
Message Broker
prelude
Glob imports for common guest module development
raw
Raw capability provider interface

Macros§

call_handler

Structs§

CapabilitiesContext
The capabilities context is the gateway through which all guest modules communicate with a host runtime. A reference to a capabilities context is passed to the call handler defined by the guest module. Individual capabilities are separated through function calls for each capability provider, including any bound opaque raw providers.

Functions§

protobytes
Utility function to easily convert a prost Message into a byte vector