[−][src]Struct wasmer::Instance
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
impl Instance
[src]
pub fn new(
module: &Module,
resolver: &dyn Resolver
) -> Result<Instance, InstantiationError>
[src]
module: &Module,
resolver: &dyn Resolver
) -> Result<Instance, InstantiationError>
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 module(&self) -> &Module
[src]
Gets the Module
associated with this instance.
pub fn store(&self) -> &Store
[src]
Returns the Store
where the Instance
belongs.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Instance
impl Send for Instance
impl !Sync for Instance
impl Unpin for Instance
impl !UnwindSafe for Instance
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,