Trait wasmi::ImportResolver
source · [−]pub trait ImportResolver {
fn resolve_func(
&self,
_module_name: &str,
field_name: &str,
_signature: &Signature
) -> Result<FuncRef, Error>;
fn resolve_global(
&self,
module_name: &str,
field_name: &str,
descriptor: &GlobalDescriptor
) -> Result<GlobalRef, Error>;
fn resolve_memory(
&self,
module_name: &str,
field_name: &str,
descriptor: &MemoryDescriptor
) -> Result<MemoryRef, Error>;
fn resolve_table(
&self,
module_name: &str,
field_name: &str,
descriptor: &TableDescriptor
) -> Result<TableRef, Error>;
}
Expand description
Resolver of a module’s dependencies.
A module have dependencies in a form of a list of imports (i.e.
tuple of a (module_name
, field_name
, descriptor
)).
The job of implementations of this trait is to provide on each import a corresponding concrete reference.
For simple use-cases you can use ImportsBuilder
.
Required methods
Resolve a function.
Returned function should match given signature
, i.e. all parameter types and return value should have exact match.
Otherwise, link-time error will occur.
fn resolve_global(
&self,
module_name: &str,
field_name: &str,
descriptor: &GlobalDescriptor
) -> Result<GlobalRef, Error>
fn resolve_global(
&self,
module_name: &str,
field_name: &str,
descriptor: &GlobalDescriptor
) -> Result<GlobalRef, Error>
Resolve a global variable.
Returned global should match given descriptor
, i.e. type and mutability
should match. Otherwise, link-time error will occur.
fn resolve_memory(
&self,
module_name: &str,
field_name: &str,
descriptor: &MemoryDescriptor
) -> Result<MemoryRef, Error>
fn resolve_memory(
&self,
module_name: &str,
field_name: &str,
descriptor: &MemoryDescriptor
) -> Result<MemoryRef, Error>
Resolve a memory.
Returned memory should match requested memory (described by the descriptor
),
i.e. initial size of a returned memory should be equal or larger than requested memory.
Furthermore, if requested memory have maximum size, returned memory either should have
equal or larger maximum size or have no maximum size at all.
If returned memory doesn’t match the requested then link-time error will occur.
fn resolve_table(
&self,
module_name: &str,
field_name: &str,
descriptor: &TableDescriptor
) -> Result<TableRef, Error>
fn resolve_table(
&self,
module_name: &str,
field_name: &str,
descriptor: &TableDescriptor
) -> Result<TableRef, Error>
Resolve a table.
Returned table should match requested table (described by the descriptor
),
i.e. initial size of a returned table should be equal or larger than requested table.
Furthermore, if requested memory have maximum size, returned memory either should have
equal or larger maximum size or have no maximum size at all.
If returned table doesn’t match the requested then link-time error will occur.