Struct wasmtime_environ::Module
source · [−]pub struct Module {Show 20 fields
pub parent: Option<usize>,
pub name: Option<String>,
pub initializers: Vec<Initializer>,
pub exports: IndexMap<String, EntityIndex>,
pub start_func: Option<FuncIndex>,
pub table_elements: Vec<TableElements>,
pub passive_elements: HashMap<ElemIndex, Box<[FuncIndex]>>,
pub passive_data: HashMap<DataIndex, Arc<[u8]>>,
pub func_names: HashMap<FuncIndex, String>,
pub types: PrimaryMap<TypeIndex, ModuleType>,
pub num_imported_funcs: usize,
pub num_imported_tables: usize,
pub num_imported_memories: usize,
pub num_imported_globals: usize,
pub functions: PrimaryMap<FuncIndex, SignatureIndex>,
pub table_plans: PrimaryMap<TableIndex, TablePlan>,
pub memory_plans: PrimaryMap<MemoryIndex, MemoryPlan>,
pub globals: PrimaryMap<GlobalIndex, Global>,
pub instances: PrimaryMap<InstanceIndex, InstanceTypeIndex>,
pub modules: PrimaryMap<ModuleIndex, ModuleTypeIndex>,
}
Expand description
A translated WebAssembly module, excluding the function bodies and memory initializers.
Fields
parent: Option<usize>
The parent index of this module, used for the module linking proposal.
This index is into the list of modules returned from compilation of a single wasm file with nested modules.
name: Option<String>
The name of this wasm module, often found in the wasm file.
initializers: Vec<Initializer>
All import records, in the order they are declared in the module.
exports: IndexMap<String, EntityIndex>
Exported entities.
start_func: Option<FuncIndex>
The module “start” function, if present.
table_elements: Vec<TableElements>
WebAssembly table initializers.
passive_elements: HashMap<ElemIndex, Box<[FuncIndex]>>
WebAssembly passive elements.
passive_data: HashMap<DataIndex, Arc<[u8]>>
WebAssembly passive data segments.
func_names: HashMap<FuncIndex, String>
WebAssembly table initializers.
types: PrimaryMap<TypeIndex, ModuleType>
Types declared in the wasm module.
num_imported_funcs: usize
Number of imported or aliased functions in the module.
num_imported_tables: usize
Number of imported or aliased tables in the module.
num_imported_memories: usize
Number of imported or aliased memories in the module.
num_imported_globals: usize
Number of imported or aliased globals in the module.
functions: PrimaryMap<FuncIndex, SignatureIndex>
Types of functions, imported and local.
table_plans: PrimaryMap<TableIndex, TablePlan>
WebAssembly tables.
memory_plans: PrimaryMap<MemoryIndex, MemoryPlan>
WebAssembly linear memory plans.
globals: PrimaryMap<GlobalIndex, Global>
WebAssembly global variables.
instances: PrimaryMap<InstanceIndex, InstanceTypeIndex>
The type of each wasm instance this module defines.
modules: PrimaryMap<ModuleIndex, ModuleTypeIndex>
The type of each nested wasm module this module contains.
Implementations
sourceimpl Module
impl Module
sourcepub fn get_passive_element(&self, index: ElemIndex) -> Option<&[FuncIndex]>
pub fn get_passive_element(&self, index: ElemIndex) -> Option<&[FuncIndex]>
Get the given passive element, if it exists.
sourcepub fn func_index(&self, defined_func: DefinedFuncIndex) -> FuncIndex
pub fn func_index(&self, defined_func: DefinedFuncIndex) -> FuncIndex
Convert a DefinedFuncIndex
into a FuncIndex
.
sourcepub fn defined_func_index(&self, func: FuncIndex) -> Option<DefinedFuncIndex>
pub fn defined_func_index(&self, func: FuncIndex) -> Option<DefinedFuncIndex>
Convert a FuncIndex
into a DefinedFuncIndex
. Returns None if the
index is an imported function.
sourcepub fn is_imported_function(&self, index: FuncIndex) -> bool
pub fn is_imported_function(&self, index: FuncIndex) -> bool
Test whether the given function index is for an imported function.
sourcepub fn table_index(&self, defined_table: DefinedTableIndex) -> TableIndex
pub fn table_index(&self, defined_table: DefinedTableIndex) -> TableIndex
Convert a DefinedTableIndex
into a TableIndex
.
sourcepub fn defined_table_index(
&self,
table: TableIndex
) -> Option<DefinedTableIndex>
pub fn defined_table_index(
&self,
table: TableIndex
) -> Option<DefinedTableIndex>
Convert a TableIndex
into a DefinedTableIndex
. Returns None if the
index is an imported table.
sourcepub fn is_imported_table(&self, index: TableIndex) -> bool
pub fn is_imported_table(&self, index: TableIndex) -> bool
Test whether the given table index is for an imported table.
sourcepub fn memory_index(&self, defined_memory: DefinedMemoryIndex) -> MemoryIndex
pub fn memory_index(&self, defined_memory: DefinedMemoryIndex) -> MemoryIndex
Convert a DefinedMemoryIndex
into a MemoryIndex
.
sourcepub fn defined_memory_index(
&self,
memory: MemoryIndex
) -> Option<DefinedMemoryIndex>
pub fn defined_memory_index(
&self,
memory: MemoryIndex
) -> Option<DefinedMemoryIndex>
Convert a MemoryIndex
into a DefinedMemoryIndex
. Returns None if the
index is an imported memory.
sourcepub fn is_imported_memory(&self, index: MemoryIndex) -> bool
pub fn is_imported_memory(&self, index: MemoryIndex) -> bool
Test whether the given memory index is for an imported memory.
sourcepub fn global_index(&self, defined_global: DefinedGlobalIndex) -> GlobalIndex
pub fn global_index(&self, defined_global: DefinedGlobalIndex) -> GlobalIndex
Convert a DefinedGlobalIndex
into a GlobalIndex
.
sourcepub fn defined_global_index(
&self,
global: GlobalIndex
) -> Option<DefinedGlobalIndex>
pub fn defined_global_index(
&self,
global: GlobalIndex
) -> Option<DefinedGlobalIndex>
Convert a GlobalIndex
into a DefinedGlobalIndex
. Returns None if the
index is an imported global.
sourcepub fn is_imported_global(&self, index: GlobalIndex) -> bool
pub fn is_imported_global(&self, index: GlobalIndex) -> bool
Test whether the given global index is for an imported global.
sourcepub fn imports(&self) -> impl Iterator<Item = (&str, Option<&str>, EntityType)>
pub fn imports(&self) -> impl Iterator<Item = (&str, Option<&str>, EntityType)>
Returns an iterator of all the imports in this module, along with their module name, field name, and type that’s being imported.
sourcepub fn type_of(&self, index: EntityIndex) -> EntityType
pub fn type_of(&self, index: EntityIndex) -> EntityType
Returns the type of an item based on its index
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Module
impl<'de> Deserialize<'de> for Module
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations
impl RefUnwindSafe for Module
impl Send for Module
impl Sync for Module
impl Unpin for Module
impl UnwindSafe for Module
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more