[][src]Struct wapc::WapcHost

pub struct WapcHost { /* fields omitted */ }

A WebAssembly host runtime for waPC-compliant WebAssembly modules

Use an instance of this struct to provide a means of invoking procedure calls by specifying an operation name and a set of bytes representing the opaque operation payload. WapcHost makes no assumptions about the contents or format of either the payload or the operation name.

Methods

impl WapcHost[src]

pub fn new(buf: &[u8]) -> Result<WapcHost>[src]

Creates a new instance of a waPC-compliant WebAssembly host runtime

pub fn call(&mut self, op: &str, payload: &[u8]) -> Result<Vec<u8>>[src]

Invokes the __guest_call function within the guest module as per the waPC specification. Provide an operation name and an opaque payload of bytes and the function returns a Result containing either an error or an opaque reply of bytes.

It is worth noting that the first time call is invoked, the WebAssembly module will be JIT-compiled. This can take up to a few seconds on debug .wasm files, but all subsequent calls will be "hot" and run at near-native speeds.

pub fn replace_module(&mut self, module: &[u8]) -> Result<()>[src]

Performs a live "hot swap" of the WebAssembly module. Since execution is assumed to be single-threaded within the environment of the WapcHost, this will not cause any pending function calls to be lost. This will replace the currently executing WebAssembly module with the new bytes.

Note: you will lose all JITted functions for this module, so the first call after a hot swap will be "cold" and take longer than regular calls. There are an enormous number of ways in which a hot swap could go horribly wrong, so please ensure you have the proper guards in place before invoking it. For example, Waxosuit implements JWT-based security that consults Open Policy Agent before allowing a hot wap.

Auto Trait Implementations

impl !Send for WapcHost

impl Unpin for WapcHost

impl !Sync for WapcHost

impl !UnwindSafe for WapcHost

impl !RefUnwindSafe for WapcHost

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]