Crate aingle_wasmer_guest[][src]

Re-exports

pub extern crate aingle_middleware_bytes;

Modules

allocation
result
serde_bytes

Wrapper types to enable optimized handling of &[u8] and Vec<u8>.

Macros

aingle_serial

unidiomatic way to derive default trait implementations of TryFrom in/out of SerializedBytes

host_externs
memory_externs
try_ptr

A simple macro to wrap return_err_ptr in an analogy to the native rust ?.

Structs

SerializedBytes

A Canonical Serialized Bytes representation for data If you have a data structure that needs a canonical byte representation use this Always round-trip through SerializedBytes via. a single TryFrom implementation. This ensures that the internal bytes of SerializedBytes are indeed canonical. The corrolary is that if bytes are NOT wrapped in SerializedBytes we can assume they are NOT canonical. Typically we need a canonical middleware when data is to be handled at the byte level by independently implemented and maintained systems.

UnsafeBytes

UnsafeBytes the only way to implement a custom round trip through bytes for SerializedBytes It is intended to be an internal implementation in TryFrom implementations The assumption is that any code using UnsafeBytes is NOT valid messagepack data This allows us to enforce that all data round-tripping through SerializedBytes is via TryFrom and also allow for custom non-messagepack canonical representations of data types.

Enums

SerializedBytesError
WasmError

Enum of all possible ERROR codes that a Zome API Function could return.

Traits

Deserialize

A data structure that can be deserialized from any data format supported by Serde.

Serialize

A data structure that can be serialized into any data format supported by Serde.

TryFrom

Simple and safe type conversions that may fail in a controlled way under some circumstances. It is the reciprocal of TryInto.

TryInto

An attempted conversion that consumes self, which may or may not be expensive.

Functions

decode
encode
host_args

Receive arguments from the host. The guest sets the type O that the host needs to match. If deserialization fails then a GuestPtr to a WasmError::Deserialize is returned. The guest should immediately return an Err back to the host. The WasmError::Deserialize enum contains the bytes that failed to deserialize so the host can unambiguously provide debug information.

host_call

Given an GuestPtr -> Len extern that we expect the host to provide:

return_err_ptr

Convert an Into into a generic Err(WasmError::Guest) as a GuestPtr returned.

return_ptr

Convert any serializable value into a GuestPtr that can be returned to the host. The host is expected to know how to consume and deserialize it.

Type Definitions

GuestPtr

a WasmSize integer that points to a position in wasm linear memory that the host and guest are sharing to communicate across function calls

Len

a WasmSize integer that represents the size of bytes to read/write to memory in direct manipulations

WasmSize

something like usize for wasm wasm has a memory limit of 4GB so offsets and lengths fit in u32

Derive Macros

Deserialize
Serialize
SerializedBytes