Struct wasmer::Instance [−][src]
pub struct Instance {
pub exports: Exports,
// some fields omitted
}
Expand description
A WebAssembly Instance is a stateful, executable
instance of a WebAssembly Module
.
Instance objects contain all the exported WebAssembly functions, memories, tables and globals that allow interacting with WebAssembly.
Spec: https://webassembly.github.io/spec/core/exec/runtime.html#module-instances
Fields
exports: Exports
The exports for an instance.
Implementations
Creates a new Instance
from a WebAssembly Module
and a
set of imports resolved by the Resolver
.
The resolver can be anything that implements the Resolver
trait,
so you can plug custom resolution for the imports, if you wish not
to use ImportObject
.
The ImportObject
is the easiest way to provide imports to the instance.
let store = Store::default();
let module = Module::new(&store, "(module)")?;
let imports = imports!{
"host" => {
"var" => Global::new(&store, Value::I32(2))
}
};
let instance = Instance::new(&module, &imports)?;
Errors
The function can return InstantiationError
s.
Those are, as defined by the spec:
- Link errors that happen when plugging the imports into the instance
- Runtime errors that happen when running the module
start
function.
pub fn new_with_config(
module: &Module,
config: InstanceConfig,
resolver: &dyn Resolver
) -> Result<Self, InstantiationError>
pub fn new_with_config(
module: &Module,
config: InstanceConfig,
resolver: &dyn Resolver
) -> Result<Self, InstantiationError>
New instance with config.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Instance
impl !UnwindSafe for Instance
Blanket Implementations
type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
pub fn pointer_metadata(
&<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
pub fn pointer_metadata(
&<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
Mutably borrows from an owned value. Read more
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more