[][src]Struct wasmer::ImportObject

pub struct ImportObject { /* fields omitted */ }

All of the import data used when instantiating.

It's suggested that you use the imports! macro instead of creating an ImportObject by hand.


use wasmer::{Exports, ImportObject, Function};

let mut import_object = ImportObject::new();
let mut env = Exports::new();

env.insert("foo", Function::new_native(foo));
import_object.register("env", env);

fn foo(n: i32) -> i32 {


impl ImportObject[src]

pub fn new() -> Self[src]

Create a new ImportObject.

pub fn get_export(&self, module: &str, name: &str) -> Option<Export>[src]

Gets an export given a module and a name


let mut import_object = ImportObject::new();
import_object.get_export("module", "name");

pub fn contains_namespace(&self, name: &str) -> bool[src]

Returns true if the ImportObject contains namespace with the provided name.

pub fn register<S, N>(
    &mut self,
    name: S,
    namespace: N
) -> Option<Box<dyn LikeNamespace>> where
    S: Into<String>,
    N: LikeNamespace + 'static, 

Register anything that implements LikeNamespace as a namespace.


let mut import_object = ImportObject::new();

import_object.register("namespace0", instance);
import_object.register("namespace1", namespace);
// ...

Trait Implementations

impl Clone for ImportObject[src]

impl Debug for ImportObject[src]

impl Default for ImportObject[src]

impl IntoIterator for ImportObject[src]

type IntoIter = ImportObjectIterator

Which kind of iterator are we turning this into?

type Item = ((String, String), Export)

The type of the elements being iterated over.

impl NamedResolver for ImportObject[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized

impl<T> Borrow<T> for T where
    T: ?Sized

impl<T> BorrowMut<T> for T where
    T: ?Sized

impl<T> ChainableNamedResolver for T where
    T: NamedResolver

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T> Resolver for T where
    T: NamedResolver

pub fn resolve(&self, _index: u32, module: &str, field: &str) -> Option<Export>[src]

By default this method will be calling NamedResolver::resolve_by_name, dismissing the provided index.

impl<T> ToOwned for T where
    T: Clone

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,