[−][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<Self, InstantiationError>
[src]
module: &Module,
resolver: &dyn Resolver
) -> Result<Self, 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
[src]
impl Send for Instance
[src]
impl Sync for Instance
[src]
impl Unpin for Instance
[src]
impl !UnwindSafe for Instance
[src]
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,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Pointable for T
pub const ALIGN: usize
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
pub unsafe fn drop(ptr: usize)
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub 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.
pub 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.
pub 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>,