pub struct ModuleInfo {Show 22 fields
pub id: ModuleId,
pub hash: Option<ModuleHash>,
pub name: Option<String>,
pub imports: IndexMap<ImportKey, ImportIndex>,
pub exports: IndexMap<String, ExportIndex>,
pub start_function: Option<FunctionIndex>,
pub table_initializers: Vec<TableInitializer>,
pub passive_elements: HashMap<ElemIndex, Box<[FunctionIndex]>>,
pub passive_data: HashMap<DataIndex, Box<[u8]>>,
pub global_initializers: PrimaryMap<LocalGlobalIndex, GlobalInit>,
pub function_names: HashMap<FunctionIndex, String>,
pub signatures: PrimaryMap<SignatureIndex, FunctionType>,
pub functions: PrimaryMap<FunctionIndex, SignatureIndex>,
pub tables: PrimaryMap<TableIndex, TableType>,
pub memories: PrimaryMap<MemoryIndex, MemoryType>,
pub globals: PrimaryMap<GlobalIndex, GlobalType>,
pub custom_sections: IndexMap<String, CustomSectionIndex>,
pub custom_sections_data: PrimaryMap<CustomSectionIndex, Box<[u8]>>,
pub num_imported_functions: usize,
pub num_imported_tables: usize,
pub num_imported_memories: usize,
pub num_imported_globals: usize,
}
Expand description
A translated WebAssembly module, excluding the function bodies and memory initializers.
IMPORTANT: since this struct will be serialized as part of the compiled module artifact,
if you change this struct, do not forget to update MetadataHeader::version
to make sure we don’t break compatibility between versions.
Fields§
§id: ModuleId
A unique identifier (within this process) for this module.
We skip serialization/deserialization of this field, as it should be computed by the process. It’s not skipped in rkyv, but that is okay, because even though it’s skipped in bincode/serde it’s still deserialized back as a garbage number, and later override from computed by the process
hash: Option<ModuleHash>
hash of the module
name: Option<String>
The name of this wasm module, often found in the wasm file.
imports: IndexMap<ImportKey, ImportIndex>
Imported entities with the (module, field, index_of_the_import)
Keeping the index_of_the_import
is important, as there can be
two same references to the same import, and we don’t want to confuse
them.
exports: IndexMap<String, ExportIndex>
Exported entities.
start_function: Option<FunctionIndex>
The module “start” function, if present.
table_initializers: Vec<TableInitializer>
WebAssembly table initializers.
passive_elements: HashMap<ElemIndex, Box<[FunctionIndex]>>
WebAssembly passive elements.
passive_data: HashMap<DataIndex, Box<[u8]>>
WebAssembly passive data segments.
global_initializers: PrimaryMap<LocalGlobalIndex, GlobalInit>
WebAssembly global initializers.
function_names: HashMap<FunctionIndex, String>
WebAssembly function names.
signatures: PrimaryMap<SignatureIndex, FunctionType>
WebAssembly function signatures.
functions: PrimaryMap<FunctionIndex, SignatureIndex>
WebAssembly functions (imported and local).
tables: PrimaryMap<TableIndex, TableType>
WebAssembly tables (imported and local).
memories: PrimaryMap<MemoryIndex, MemoryType>
WebAssembly linear memories (imported and local).
globals: PrimaryMap<GlobalIndex, GlobalType>
WebAssembly global variables (imported and local).
custom_sections: IndexMap<String, CustomSectionIndex>
Custom sections in the module.
custom_sections_data: PrimaryMap<CustomSectionIndex, Box<[u8]>>
The data for each CustomSection in the module.
num_imported_functions: usize
Number of imported functions in the module.
num_imported_tables: usize
Number of imported tables in the module.
num_imported_memories: usize
Number of imported memories in the module.
num_imported_globals: usize
Number of imported globals in the module.
Implementations§
Source§impl ModuleInfo
impl ModuleInfo
Sourcepub fn hash(&self) -> Option<ModuleHash>
pub fn hash(&self) -> Option<ModuleHash>
Returns the module hash if available
Sourcepub fn get_passive_element(&self, index: ElemIndex) -> Option<&[FunctionIndex]>
pub fn get_passive_element(&self, index: ElemIndex) -> Option<&[FunctionIndex]>
Get the given passive element, if it exists.
Sourcepub fn exported_signatures(&self) -> Vec<FunctionType>
pub fn exported_signatures(&self) -> Vec<FunctionType>
Get the exported signatures of the module
Sourcepub fn exports(&self) -> ExportsIterator<impl Iterator<Item = ExportType> + '_> ⓘ
pub fn exports(&self) -> ExportsIterator<impl Iterator<Item = ExportType> + '_> ⓘ
Get the export types of the module
Sourcepub fn imports(&self) -> ImportsIterator<impl Iterator<Item = ImportType> + '_> ⓘ
pub fn imports(&self) -> ImportsIterator<impl Iterator<Item = ImportType> + '_> ⓘ
Get the import types of the module
Sourcepub fn custom_sections<'a>(
&'a self,
name: &'a str,
) -> impl Iterator<Item = Box<[u8]>> + 'a
pub fn custom_sections<'a>( &'a self, name: &'a str, ) -> impl Iterator<Item = Box<[u8]>> + 'a
Get the custom sections of the module given a name
.
Sourcepub fn func_index(&self, local_func: LocalFunctionIndex) -> FunctionIndex
pub fn func_index(&self, local_func: LocalFunctionIndex) -> FunctionIndex
Convert a LocalFunctionIndex
into a FunctionIndex
.
Sourcepub fn local_func_index(
&self,
func: FunctionIndex,
) -> Option<LocalFunctionIndex>
pub fn local_func_index( &self, func: FunctionIndex, ) -> Option<LocalFunctionIndex>
Convert a FunctionIndex
into a LocalFunctionIndex
. Returns None if the
index is an imported function.
Sourcepub fn is_imported_function(&self, index: FunctionIndex) -> bool
pub fn is_imported_function(&self, index: FunctionIndex) -> bool
Test whether the given function index is for an imported function.
Sourcepub fn table_index(&self, local_table: LocalTableIndex) -> TableIndex
pub fn table_index(&self, local_table: LocalTableIndex) -> TableIndex
Convert a LocalTableIndex
into a TableIndex
.
Sourcepub fn local_table_index(&self, table: TableIndex) -> Option<LocalTableIndex>
pub fn local_table_index(&self, table: TableIndex) -> Option<LocalTableIndex>
Convert a TableIndex
into a LocalTableIndex
. 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, local_memory: LocalMemoryIndex) -> MemoryIndex
pub fn memory_index(&self, local_memory: LocalMemoryIndex) -> MemoryIndex
Convert a LocalMemoryIndex
into a MemoryIndex
.
Sourcepub fn local_memory_index(
&self,
memory: MemoryIndex,
) -> Option<LocalMemoryIndex>
pub fn local_memory_index( &self, memory: MemoryIndex, ) -> Option<LocalMemoryIndex>
Convert a MemoryIndex
into a LocalMemoryIndex
. 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, local_global: LocalGlobalIndex) -> GlobalIndex
pub fn global_index(&self, local_global: LocalGlobalIndex) -> GlobalIndex
Convert a LocalGlobalIndex
into a GlobalIndex
.
Sourcepub fn local_global_index(
&self,
global: GlobalIndex,
) -> Option<LocalGlobalIndex>
pub fn local_global_index( &self, global: GlobalIndex, ) -> Option<LocalGlobalIndex>
Convert a GlobalIndex
into a LocalGlobalIndex
. 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 imported_function_types(&self) -> impl Iterator<Item = FunctionType> + '_
pub fn imported_function_types(&self) -> impl Iterator<Item = FunctionType> + '_
Get the imported function types of the module.
Trait Implementations§
Source§impl Archive for ModuleInfo
impl Archive for ModuleInfo
Source§type Archived = <ArchivableModuleInfo as Archive>::Archived
type Archived = <ArchivableModuleInfo as Archive>::Archived
Source§type Resolver = <ArchivableModuleInfo as Archive>::Resolver
type Resolver = <ArchivableModuleInfo as Archive>::Resolver
Source§fn resolve(&self, resolver: Self::Resolver, out: Place<Self::Archived>)
fn resolve(&self, resolver: Self::Resolver, out: Place<Self::Archived>)
Source§const COPY_OPTIMIZATION: CopyOptimization<Self> = _
const COPY_OPTIMIZATION: CopyOptimization<Self> = _
serialize
. Read moreSource§impl Clone for ModuleInfo
impl Clone for ModuleInfo
Source§fn clone(&self) -> ModuleInfo
fn clone(&self) -> ModuleInfo
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for ModuleInfo
impl Debug for ModuleInfo
Source§impl Default for ModuleInfo
impl Default for ModuleInfo
Source§fn default() -> ModuleInfo
fn default() -> ModuleInfo
Source§impl Display for ModuleInfo
impl Display for ModuleInfo
Source§impl PartialEq for ModuleInfo
impl PartialEq for ModuleInfo
impl Eq for ModuleInfo
Auto Trait Implementations§
impl Freeze for ModuleInfo
impl RefUnwindSafe for ModuleInfo
impl Send for ModuleInfo
impl Sync for ModuleInfo
impl Unpin for ModuleInfo
impl UnwindSafe for ModuleInfo
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> ArchiveUnsized for Twhere
T: Archive,
impl<T> ArchiveUnsized for Twhere
T: Archive,
Source§type Archived = <T as Archive>::Archived
type Archived = <T as Archive>::Archived
Archive
, it may be
unsized. Read moreSource§fn archived_metadata(
&self,
) -> <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata
fn archived_metadata( &self, ) -> <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out
indicating that a T
is niched.