[][src]Crate wascc_actor

wascc-actor

The wascc-actor library provides WebAssembly module developers with access to the wascc host runtime. Each actor module has a single receive function, declared with the actor_receive! macro. Inside this receive function, the actor 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 actor module to ensure that the capability provider will be able to understand whichever messages it sends.

Example

extern crate wascc_actor as actor;

use actor::prelude::*;

actor_receive!(receive);

pub fn receive(ctx: &CapabilitiesContext, operation: &str, msg: &[u8]) -> ReceiveResult {
    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]) -> ReceiveResult {
    Ok(vec![])
}

Re-exports

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

Modules

errors

Errors

kv

Key-Value Store

msg

Message Broker

prelude

Glob imports for common actor module development

raw

Raw capability provider interface

Macros

actor_receive

Actor developers will use this macro to set up their central receive function

Structs

CapabilitiesContext

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

Traits

KeyValueStore

Represents an abstraction around a client consuming a Key-Value store provided by the host

MessageBroker

Represents an abstraction around a client consuming a message broker provided by the host

RawCapability

A loosely typed, opaque client consuming a capability provider in the host runtime

Functions

protobytes

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

Type Definitions

ReceiveResult
Result