Module holochain_wasmer_host::prelude
source · [−]Re-exports
Modules
Wrapper types to enable optimized handling of
&[u8]
and Vec<u8>
.The
vm
module re-exports wasmer-vm types.A simple event-driven library for parsing WebAssembly binary files
(or streams).
Macros
unidiomatic way to derive default trait implementations of TryFrom in/out of SerializedBytes
Generate an
ImportObject
easily with the imports!
macro.Helper macro for returning an error from a WASM.
Structs
The
Array
marker type. This type can be used like WasmPtr<T, Array>
to get access to methodsAtomically.
Tunable parameters for WebAssembly compilation.
This is the reference implementation of the
Tunables
trait,
used by default.Units of WebAssembly memory in terms of 8-bit bytes.
Global configuration options used to create an
wasmer_engine::Engine
and customize its behavior.A descriptor for an exported WebAssembly value.
Exports is a special kind of map that allows easily unwrapping
the types of instances.
An iterator over exports.
Controls which experimental features will be enabled.
Features usually have a corresponding WebAssembly proposal.
Description of a frame in a backtrace for a
RuntimeError::trace
.A WebAssembly
function
instance.The signature of a function that is either implemented
in a Wasm module or exposed to Wasm by the host.
A WebAssembly
global
instance.WebAssembly global.
All of the import data used when instantiating.
Iterator for an
ImportObject
’s exports.A descriptor for an imported value into a wasm module.
The
Item
marker type. This is the default and does not usually need to be
specified.Lazily init an item
Index type of a function defined locally inside the WebAssembly module.
A WebAssembly
memory
instance.A descriptor for a WebAssembly memory type.
A view into a memory.
A error in the middleware.
The state of the binary reader. Exposed to middlewares to push their outputs.
A WebAssembly Module contains stateless WebAssembly
code that has already been compiled and can be instantiated
multiple times.
A
Resolver
that links two resolvers together in a chain.A WebAssembly function that can be called natively
(using the Native ABI).
Units of WebAssembly pages (as specified to be 65,536 bytes).
A struct representing an aborted instruction execution, with a message
indicating the cause.
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 serialization when data is to be handled at the byte level by
independently implemented and maintained systems.
The store represents all global state that can be manipulated by
WebAssembly programs. It consists of the runtime representation
of all instances of functions, tables, memories, and globals that
have been allocated during the lifetime of the abstract machine.
A WebAssembly
table
instance.A descriptor for a table in a WebAssembly module.
This is the target that we will use for compiling
the WebAssembly ModuleInfo, and then run it.
A target “triple”. Historically such things had three fields, though they’ve
added additional fields over time.
The Universal builder
A compiled wasm module, ready to be instantiated.
A WebAssembly
Universal
Engine.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.
A mutable Wasm-memory location.
Wraps a WasmErrorInner with a file and line number.
The easiest way to generate this is with the
wasm_error!
macro that will
insert the correct file/line and can create strings by forwarding args to
the format!
macro.A zero-cost type that represents a pointer to something in Wasm linear
memory.
Enums
The “architecture” field, which in some cases also specifies a specific
subarchitecture.
The calling convention, which specifies things like which registers are
used for passing arguments, which registers are callee-saved, and so on.
The WebAssembly.CompileError object indicates an error during
WebAssembly decoding or validation.
The nomenclature is inspired by the
cpuid
crate.
The list of supported features was initially retrieved from
cranelift-native
.Possible optimization levels for the Cranelift codegen backend.
The Deserialize error can occur when loading a
compiled Module from a binary.
The value of an export passed from one instance to another.
An entity to export.
An
Extern
is the runtime representation of an entity that
can be imported or exported.A list of all possible types which can be externally referenced from a
WebAssembly module.
Globals are initialized via the
const
operators or by referring to another import.An error while initializing the user supplied host env with the
WasmerEnv
trait.An error while instantiating a module.
The WebAssembly.LinkError object indicates an error during
module instantiation (besides traps from the start function).
Error type describing things that can go wrong when operating on Wasm Memories.
Indicator of whether a global is mutable or not
The “operating system” field, which sometimes implies an environment, and
sometimes isn’t an actual operating system.
The error that can happen while parsing a
str
to retrieve a CpuFeature
.The Serialize error can occur when serializing a
compiled Module into a binary.
A list of all possible value types in WebAssembly.
A list of all possible value types in WebAssembly.
A WebAssembly translation error.
Enum of all possible ERROR states that wasm can encounter.
Constants
The
Triple
of the current host.Version number of this crate.
The number of pages we can have before we run out of byte index space.
The minimum number of pages allowed.
WebAssembly page sizes are fixed to be 64KiB.
Note: large page support may be added in an opt-in manner in the future.
Traits
A trait for chaining resolvers together.
The compiler configuration options.
A data structure that can be deserialized from any data format supported
by Serde.
A unimplemented Wasmer
Engine
.This trait is used to mark types as gettable from an
Instance
.A trait to convert a Rust value to a
WasmNativeType
value,
or to convert WasmNativeType
value to a Rust value.A function middleware specialized for a single function.
The
HostFunction
trait represents the set of functions that
can be used as host function. To uphold this statement, it is
necessary for a function to be transformed into a pointer to
VMFunctionBody
.The
LikeNamespace
trait represents objects that act as a namespace for imports.
For example, an Instance
or Namespace
could be
considered namespaces that could provide imports to an instance.A shared builder for function middlewares.
Import resolver connects imports with available exported values.
Import resolver connects imports with available exported values.
A data structure that can be serialized into any data format supported
by Serde.
A trait represinting any object that lives in the
Store
.Simple and safe type conversions that may fail in a controlled
way under some circumstances. It is the reciprocal of
TryInto
.An attempted conversion that consumes
self
, which may or may not be
expensive.An engine delegates the creation of memories, tables, and globals
to a foreign implementor of this trait.
Trait for a Value type. A Value type is a type that is always valid and may
be safely copied.
The
WasmTypeList
trait represents a tuple (list) of Wasm
typed values. It is used to get low-level representation of
such a tuple.Trait for initializing the environments passed to host functions after
instantiation but before execution.
Functions
Check if the provided bytes are wasm-like
Given a pointer and a length, return a
u64
merged GuestPtrLen
.
Works via a simple bitwise shift to move the pointer to high bits then OR
the length into the low bits.Raises a user-defined trap immediately.
Given a merged
GuestPtrLen
, split out a u32
pointer and length.
Performs the inverse of merge_u64
. Takes the low u32
bits as the length
then shifts the 32 high bits down and takes those as the pointer.Parses in-memory bytes as either the WebAssembly Text format, or a
binary WebAssembly module.
Type Definitions
A
WasmSize
that points to a position in wasm linear memory that the host
and guest are sharing to communicate across function calls.Enough bits to fit a pointer and length into so we can return it. The externs
defined as “C” don’t support multiple return values (unlike wasm). The native
Rust support for wasm externs is not stable at the time of writing.
A
WasmSize
integer that represents the size of bytes to read/write to memory.A mutual exclusion primitive useful for protecting shared data
WebAssembly computations manipulate values of basic value types:
WebAssembly computations manipulate values of basic value types:
A convenient alias for a
Result
that uses WasmError
as the error type.Something like
usize
for wasm.
Wasm has a memory limit of 4GB so offsets and lengths fit in u32
.