Struct wasmer_vm::ModuleInfo
source · [−]pub struct ModuleInfo {Show 21 fields
pub id: ModuleId,
pub name: Option<String>,
pub imports: IndexMap<(String, String, u32), ImportIndex, RandomState>,
pub exports: IndexMap<String, ExportIndex, RandomState>,
pub start_function: Option<FunctionIndex>,
pub table_initializers: Vec<TableInitializer, Global>,
pub passive_elements: HashMap<ElemIndex, Box<[FunctionIndex], Global>, RandomState>,
pub passive_data: HashMap<DataIndex, Arc<[u8]>, RandomState>,
pub global_initializers: PrimaryMap<LocalGlobalIndex, GlobalInit>,
pub function_names: HashMap<FunctionIndex, String, RandomState>,
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, RandomState>,
pub custom_sections_data: PrimaryMap<CustomSectionIndex, Arc<[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.
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
name: Option<String>
The name of this wasm module, often found in the wasm file.
imports: IndexMap<(String, String, u32), ImportIndex, RandomState>
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, RandomState>
Exported entities.
start_function: Option<FunctionIndex>
The module “start” function, if present.
table_initializers: Vec<TableInitializer, Global>
WebAssembly table initializers.
passive_elements: HashMap<ElemIndex, Box<[FunctionIndex], Global>, RandomState>
WebAssembly passive elements.
passive_data: HashMap<DataIndex, Arc<[u8]>, RandomState>
WebAssembly passive data segments.
global_initializers: PrimaryMap<LocalGlobalIndex, GlobalInit>
WebAssembly global initializers.
function_names: HashMap<FunctionIndex, String, RandomState>
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, RandomState>
Custom sections in the module.
custom_sections_data: PrimaryMap<CustomSectionIndex, Arc<[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
sourceimpl ModuleInfo
impl ModuleInfo
sourcepub fn new() -> ModuleInfo
pub fn new() -> ModuleInfo
Allocates the module data structures.
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, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn exported_signatures(&self) -> Vec<FunctionType, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Get the exported signatures of the module
sourcepub fn exports(
&self
) -> ExportsIterator<impl Iterator<Item = ExportType<ExternType>>>ⓘNotable traits for ExportsIterator<I>impl<I> Iterator for ExportsIterator<I> where
I: Iterator<Item = ExportType<ExternType>>, type Item = ExportType<ExternType>;
pub fn exports(
&self
) -> ExportsIterator<impl Iterator<Item = ExportType<ExternType>>>ⓘNotable traits for ExportsIterator<I>impl<I> Iterator for ExportsIterator<I> where
I: Iterator<Item = ExportType<ExternType>>, type Item = ExportType<ExternType>;
I: Iterator<Item = ExportType<ExternType>>, type Item = ExportType<ExternType>;
Get the export types of the module
sourcepub fn imports(
&self
) -> ImportsIterator<impl Iterator<Item = ImportType<ExternType>>>ⓘNotable traits for ImportsIterator<I>impl<I> Iterator for ImportsIterator<I> where
I: Iterator<Item = ImportType<ExternType>>, type Item = ImportType<ExternType>;
pub fn imports(
&self
) -> ImportsIterator<impl Iterator<Item = ImportType<ExternType>>>ⓘNotable traits for ImportsIterator<I>impl<I> Iterator for ImportsIterator<I> where
I: Iterator<Item = ImportType<ExternType>>, type Item = ImportType<ExternType>;
I: Iterator<Item = ImportType<ExternType>>, type Item = ImportType<ExternType>;
Get the import types of the module
sourcepub fn custom_sections(
&'a self,
name: &'a str
) -> impl Iterator<Item = Arc<[u8]>> + 'a
pub fn custom_sections(
&'a self,
name: &'a str
) -> impl Iterator<Item = Arc<[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
sourceimpl Archive for ModuleInfo
impl Archive for ModuleInfo
type Archived = <ArchivableModuleInfo as Archive>::Archived
type Archived = <ArchivableModuleInfo as Archive>::Archived
The archived representation of this type. Read more
type Resolver = <ArchivableModuleInfo as Archive>::Resolver
type Resolver = <ArchivableModuleInfo as Archive>::Resolver
The resolver for this type. It must contain all the additional information from serializing needed to make the archived type from the normal type. Read more
sourceunsafe fn resolve(
&self,
pos: usize,
resolver: <ModuleInfo as Archive>::Resolver,
out: *mut <ModuleInfo as Archive>::Archived
)
unsafe fn resolve(
&self,
pos: usize,
resolver: <ModuleInfo as Archive>::Resolver,
out: *mut <ModuleInfo as Archive>::Archived
)
Creates the archived version of this value at the given position and writes it to the given output. Read more
sourceimpl Clone for ModuleInfo
impl Clone for ModuleInfo
sourcefn clone(&self) -> ModuleInfo
fn clone(&self) -> ModuleInfo
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for ModuleInfo
impl Debug for ModuleInfo
sourceimpl Default for ModuleInfo
impl Default for ModuleInfo
sourcefn default() -> ModuleInfo
fn default() -> ModuleInfo
Returns the “default value” for a type. Read more
sourceimpl<'de> Deserialize<'de> for ModuleInfo
impl<'de> Deserialize<'de> for ModuleInfo
sourcefn deserialize<__D>(
__deserializer: __D
) -> Result<ModuleInfo, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<ModuleInfo, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl<D> Deserialize<ModuleInfo, D> for <ModuleInfo as Archive>::Archived where
D: Fallible + SharedDeserializeRegistry + ?Sized,
impl<D> Deserialize<ModuleInfo, D> for <ModuleInfo as Archive>::Archived where
D: Fallible + SharedDeserializeRegistry + ?Sized,
sourcefn deserialize(
&self,
deserializer: &mut D
) -> Result<ModuleInfo, <D as Fallible>::Error>
fn deserialize(
&self,
deserializer: &mut D
) -> Result<ModuleInfo, <D as Fallible>::Error>
Deserializes using the given deserializer
sourceimpl Display for ModuleInfo
impl Display for ModuleInfo
sourceimpl From<ArchivableModuleInfo> for ModuleInfo
impl From<ArchivableModuleInfo> for ModuleInfo
sourcefn from(it: ArchivableModuleInfo) -> ModuleInfo
fn from(it: ArchivableModuleInfo) -> ModuleInfo
Converts to this type from the input type.
sourceimpl MemoryUsage for ModuleInfo
impl MemoryUsage for ModuleInfo
sourcefn size_of_val(&self, visited: &mut dyn MemoryUsageTracker) -> usize
fn size_of_val(&self, visited: &mut dyn MemoryUsageTracker) -> usize
Returns the size of the referenced value in bytes. Read more
sourceimpl PartialEq<ModuleInfo> for ModuleInfo
impl PartialEq<ModuleInfo> for ModuleInfo
sourceimpl Serialize for ModuleInfo
impl Serialize for ModuleInfo
sourcefn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
sourceimpl<S> Serialize<S> for ModuleInfo where
S: Serializer + SharedSerializeRegistry + ScratchSpace + ?Sized,
impl<S> Serialize<S> for ModuleInfo where
S: Serializer + SharedSerializeRegistry + ScratchSpace + ?Sized,
impl Eq for ModuleInfo
Auto Trait Implementations
impl RefUnwindSafe for ModuleInfo
impl Send for ModuleInfo
impl Sync for ModuleInfo
impl Unpin for ModuleInfo
impl UnwindSafe for ModuleInfo
Blanket Implementations
impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
fn pointer_metadata(
&<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
fn pointer_metadata(
&<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
impl<T> ArchiveUnsized for T where
T: Archive,
impl<T> ArchiveUnsized for T where
T: Archive,
type Archived = <T as Archive>::Archived
type Archived = <T as Archive>::Archived
The archived counterpart of this type. Unlike Archive
, it may be unsized. Read more
type MetadataResolver = ()
type MetadataResolver = ()
The resolver for the metadata of this type. Read more
unsafe fn resolve_metadata(
&self,
usize,
<T as ArchiveUnsized>::MetadataResolver,
*mut <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata
)
unsafe fn resolve_metadata(
&self,
usize,
<T as ArchiveUnsized>::MetadataResolver,
*mut <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata
)
Creates the archived version of the metadata for this value at the given position and writes it to the given output. Read more
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<F, W, T, D> Deserialize<With<T, W>, D> for F where
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
F: ?Sized,
impl<F, W, T, D> Deserialize<With<T, W>, D> for F where
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
F: ?Sized,
fn deserialize(
&self,
deserializer: &mut D
) -> Result<With<T, W>, <D as Fallible>::Error>
fn deserialize(
&self,
deserializer: &mut D
) -> Result<With<T, W>, <D as Fallible>::Error>
Deserializes using the given deserializer
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.
impl<T, S> SerializeUnsized<S> for T where
T: Serialize<S>,
S: Serializer + ?Sized,
impl<T, S> SerializeUnsized<S> for T where
T: Serialize<S>,
S: Serializer + ?Sized,
fn serialize_unsized(
&self,
serializer: &mut S
) -> Result<usize, <S as Fallible>::Error>
fn serialize_unsized(
&self,
serializer: &mut S
) -> Result<usize, <S as Fallible>::Error>
Writes the object and returns the position of the archived type.
fn serialize_metadata(&self, &mut S) -> Result<(), <S as Fallible>::Error>
fn serialize_metadata(&self, &mut S) -> Result<(), <S as Fallible>::Error>
Serializes the metadata for the given type.
sourceimpl<T> Upcastable for T where
T: 'static + Any + Send + Sync,
impl<T> Upcastable for T where
T: 'static + Any + Send + Sync,
sourcefn upcast_any_ref(&self) -> &(dyn Any + 'static)
fn upcast_any_ref(&self) -> &(dyn Any + 'static)
upcast ref
sourcefn upcast_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn upcast_any_mut(&mut self) -> &mut (dyn Any + 'static)
upcast mut ref