Struct wasmi::ImportsBuilder

source ·
pub struct ImportsBuilder<'a> { /* private fields */ }
Expand description

Convenience builder of ImportResolver.

With help of this builder, you can easily create ImportResolver, just by adding needed resolvers by names.

Examples

use wasmi::{ModuleInstance, ImportsBuilder};

let imports = ImportsBuilder::new()
    .with_resolver("env", &EnvModuleResolver)
    // Note, that ModuleInstance can be a resolver too.
    .with_resolver("other_instance", &other_instance);
let instance = ModuleInstance::new(&module, &imports)?.assert_no_start();

Implementations§

source§

impl<'a> ImportsBuilder<'a>

source

pub fn new() -> ImportsBuilder<'a>

Create an empty ImportsBuilder.

source

pub fn with_resolver<N: Into<String>>( self, name: N, resolver: &'a dyn ModuleImportResolver ) -> Self

Register an resolver by a name.

source

pub fn push_resolver<N: Into<String>>( &mut self, name: N, resolver: &'a dyn ModuleImportResolver )

Register an resolver by a name.

Mutable borrowed version.

Trait Implementations§

source§

impl<'a> Default for ImportsBuilder<'a>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<'a> ImportResolver for ImportsBuilder<'a>

source§

fn resolve_func( &self, module_name: &str, field_name: &str, signature: &Signature ) -> Result<FuncRef, Error>

Resolve a function. Read more
source§

fn resolve_global( &self, module_name: &str, field_name: &str, global_type: &GlobalDescriptor ) -> Result<GlobalRef, Error>

Resolve a global variable. Read more
source§

fn resolve_memory( &self, module_name: &str, field_name: &str, memory_type: &MemoryDescriptor ) -> Result<MemoryRef, Error>

Resolve a memory. Read more
source§

fn resolve_table( &self, module_name: &str, field_name: &str, table_type: &TableDescriptor ) -> Result<TableRef, Error>

Resolve a table. Read more

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for ImportsBuilder<'a>

§

impl<'a> !Send for ImportsBuilder<'a>

§

impl<'a> !Sync for ImportsBuilder<'a>

§

impl<'a> Unpin for ImportsBuilder<'a>

§

impl<'a> !UnwindSafe for ImportsBuilder<'a>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> Downcast for Twhere T: Any,

source§

fn into_any(self: Box<T, Global>) -> Box<dyn Any, Global>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.