pub struct ModuleInfo {
Show 18 fields pub id: ModuleId, pub name: Option<String>, pub imports: IndexMap<(String, String, u32), ImportIndex>, pub exports: IndexMap<String, ExportIndex>, pub start_function: Option<FunctionIndex>, pub table_initializers: Vec<OwnedTableInitializer>, pub passive_elements: BTreeMap<ElemIndex, Box<[FunctionIndex]>>, pub passive_data: BTreeMap<DataIndex, Arc<[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, Arc<[u8]>>, pub import_counts: ImportCounts,
}
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>

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<OwnedTableInitializer>

WebAssembly table initializers.

§passive_elements: BTreeMap<ElemIndex, Box<[FunctionIndex]>>

WebAssembly passive elements.

§passive_data: BTreeMap<DataIndex, Arc<[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, Arc<[u8]>>

The data for each CustomSection in the module.

§import_counts: ImportCounts

The counts of imported entities.

Implementations§

source§

impl ModuleInfo

source

pub fn new() -> Self

Allocates the module data structures.

source

pub fn get_passive_element(&self, index: ElemIndex) -> Option<&[FunctionIndex]>

Get the given passive element, if it exists.

source

pub fn exported_signatures(&self) -> Vec<FunctionType>

Get the exported signatures of the module

source

pub fn custom_sections<'a>( &'a self, name: &'a str ) -> impl Iterator<Item = Arc<[u8]>> + 'a

Get the custom sections of the module given a name.

source

pub fn func_index(&self, local_func: LocalFunctionIndex) -> FunctionIndex

Convert a LocalFunctionIndex into a FunctionIndex.

source

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.

source

pub fn is_imported_function(&self, index: FunctionIndex) -> bool

Test whether the given function index is for an imported function.

source

pub fn table_index(&self, local_table: LocalTableIndex) -> TableIndex

Convert a LocalTableIndex into a TableIndex.

source

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.

source

pub fn is_imported_table(&self, index: TableIndex) -> bool

Test whether the given table index is for an imported table.

source

pub fn memory_index(&self, local_memory: LocalMemoryIndex) -> MemoryIndex

Convert a LocalMemoryIndex into a MemoryIndex.

source

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.

source

pub fn is_imported_memory(&self, index: MemoryIndex) -> bool

Test whether the given memory index is for an imported memory.

source

pub fn global_index(&self, local_global: LocalGlobalIndex) -> GlobalIndex

Convert a LocalGlobalIndex into a GlobalIndex.

source

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.

source

pub fn is_imported_global(&self, index: GlobalIndex) -> bool

Test whether the given global index is for an imported global.

source

pub fn name(&self) -> String

Get the Module name

source

pub fn imported_function_types<'a>( &'a self ) -> impl Iterator<Item = FunctionType> + 'a

Get the imported function types of the module.

Trait Implementations§

source§

impl Archive for ModuleInfo

§

type Archived = <ArchivableModuleInfo as Archive>::Archived

The archived representation of this type. Read more
§

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.
source§

unsafe fn resolve( &self, pos: usize, resolver: Self::Resolver, out: *mut Self::Archived )

Creates the archived version of this value at the given position and writes it to the given output. Read more
source§

impl Clone for ModuleInfo

source§

fn clone(&self) -> ModuleInfo

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for ModuleInfo

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for ModuleInfo

source§

fn default() -> ModuleInfo

Returns the “default value” for a type. Read more
source§

impl<D: Fallible + ?Sized + SharedDeserializeRegistry> Deserialize<ModuleInfo, D> for Archived<ModuleInfo>

source§

fn deserialize(&self, deserializer: &mut D) -> Result<ModuleInfo, D::Error>

Deserializes using the given deserializer
source§

impl Display for ModuleInfo

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq<ModuleInfo> for ModuleInfo

source§

fn eq(&self, other: &ModuleInfo) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<S: Serializer + SharedSerializeRegistry + ScratchSpace + ?Sized> Serialize<S> for ModuleInfo

source§

fn serialize(&self, serializer: &mut S) -> Result<Self::Resolver, S::Error>

Writes the dependencies for the object and returns a resolver that can create the archived type.
source§

impl Eq for ModuleInfo

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> ArchivePointee for T

§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
source§

impl<T> ArchiveUnsized for Twhere T: Archive,

§

type Archived = <T as Archive>::Archived

The archived counterpart of this type. Unlike Archive, it may be unsized. Read more
§

type MetadataResolver = ()

The resolver for the metadata of this type. Read more
source§

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
source§

unsafe fn resolve_unsized( &self, from: usize, to: usize, resolver: Self::MetadataResolver, out: *mut RelPtr<Self::Archived, <isize as Archive>::Archived> )

Resolves a relative pointer to this value with the given from and to and writes it to the given output. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

source§

fn deserialize( &self, deserializer: &mut D ) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
source§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointee for T

§

type Metadata = ()

The type for metadata in pointers and references to Self.
source§

impl<T, S> SerializeUnsized<S> for Twhere T: Serialize<S>, S: Serializer + ?Sized,

source§

fn serialize_unsized( &self, serializer: &mut S ) -> Result<usize, <S as Fallible>::Error>

Writes the object and returns the position of the archived type.
source§

fn serialize_metadata(&self, _: &mut S) -> Result<(), <S as Fallible>::Error>

Serializes the metadata for the given type.
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.