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>
impl<'a> ImportsBuilder<'a>
sourcepub fn new() -> ImportsBuilder<'a>
pub fn new() -> ImportsBuilder<'a>
Create an empty ImportsBuilder
.
sourcepub fn with_resolver<N: Into<String>>(
self,
name: N,
resolver: &'a dyn ModuleImportResolver
) -> Self
pub fn with_resolver<N: Into<String>>( self, name: N, resolver: &'a dyn ModuleImportResolver ) -> Self
Register an resolver by a name.
sourcepub fn push_resolver<N: Into<String>>(
&mut self,
name: N,
resolver: &'a dyn ModuleImportResolver
)
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>
impl<'a> Default for ImportsBuilder<'a>
source§impl<'a> ImportResolver for ImportsBuilder<'a>
impl<'a> ImportResolver for ImportsBuilder<'a>
source§fn resolve_func(
&self,
module_name: &str,
field_name: &str,
signature: &Signature
) -> Result<FuncRef, Error>
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>
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>
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>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere T: Any,
source§fn into_any(self: Box<T, Global>) -> Box<dyn Any, Global>
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>
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)
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)
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.