[][src]Crate wapc_guest

wapc-guest

The wapc-guest library provides WebAssembly module developers with access to a waPC-compliant host runtime. Each guest module has a single call handler, declared with the wapc_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.

Example

extern crate wapc_guest as guest;

use guest::prelude::*;

wapc_handler!(handle_wapc);

pub fn handle_wapc(operation: &str, msg: &[u8]) -> CallResult {
    match operation {
        "sample:Guest!Hello" => hello_world(msg),
        _ => Err("bad dispatch".into()),
    }     
}

fn hello_world(
   _msg: &[u8]) -> CallResult {
   let _res = host_call("sample:Host", "Call", b"hello")?;
    Ok(vec![])
}

Modules

errors

Errors

prelude

Glob imports for common guest module development

Macros

wapc_handler

Functions

__console_log
__guest_error
__guest_request
__guest_response
__host_call
__host_error
__host_error_len
__host_response
__host_response_len
console_log
host_call

The function through which all host calls take place.

Type Definitions

Result

WaPC Guest SDK result type