pub struct Module<'a> {Show 13 fields
pub sections: Vec<RawSection<'a>>,
pub types: Vec<FuncType>,
pub imports: Vec<Import>,
pub exports: Vec<Export>,
pub functions: Vec<TypeIdx>,
pub tables: Vec<TableType>,
pub elements: Vec<ElementSegment<'a>>,
pub globals: Vec<Global<'a>>,
pub memories: Vec<MemType>,
pub data: Vec<DataSegment<'a>>,
pub start: Option<FuncIdx>,
pub data_count: Option<u32>,
pub codes: Vec<CodeBody<'a>>,
}Expand description
A parsed WASM module. Contains the raw section data segmented by type.
At Phase 0, section bodies are stored as raw bytes. Later phases will parse type entries, imports, function bodies, etc.
Fields§
§sections: Vec<RawSection<'a>>All sections in the order they appeared, as raw byte spans.
types: Vec<FuncType>Decoded function signatures from the type section.
imports: Vec<Import>Imported items declared by the module.
exports: Vec<Export>Exported items declared by the module.
functions: Vec<TypeIdx>Type indices for module-defined (non-imported) functions.
tables: Vec<TableType>Defined tables from the table section.
elements: Vec<ElementSegment<'a>>Defined element segments from the element section.
globals: Vec<Global<'a>>Defined globals from the global section.
memories: Vec<MemType>Defined memories from the memory section.
data: Vec<DataSegment<'a>>Defined data segments from the data section.
start: Option<FuncIdx>Optional declared start function.
data_count: Option<u32>Optional declared data count.
codes: Vec<CodeBody<'a>>Function bodies from the code section.
Implementations§
Source§impl<'a> Module<'a>
impl<'a> Module<'a>
Sourcepub fn decode(bytes: &'a [u8]) -> Result<Self, DecodeError>
pub fn decode(bytes: &'a [u8]) -> Result<Self, DecodeError>
Decode a WASM binary into a Module.
This validates the preamble (magic + version), parses section boundaries, and checks section ordering. It does NOT validate section contents.
Sourcepub fn section(&self, id: SectionId) -> Option<&RawSection<'a>>
pub fn section(&self, id: SectionId) -> Option<&RawSection<'a>>
Get the first section with the given ID, if present.
Sourcepub fn elements(&self) -> &[ElementSegment<'a>]
pub fn elements(&self) -> &[ElementSegment<'a>]
Defined element segments from the element section.
Sourcepub fn imported_function_count(&self) -> usize
pub fn imported_function_count(&self) -> usize
Number of imported functions in the function index space.
Sourcepub fn data(&self) -> &[DataSegment<'a>]
pub fn data(&self) -> &[DataSegment<'a>]
Defined data segments from the data section.
Sourcepub fn data_count(&self) -> Option<u32>
pub fn data_count(&self) -> Option<u32>
Declared data count, if present.
Sourcepub fn custom_sections(&self) -> impl Iterator<Item = &RawSection<'a>>
pub fn custom_sections(&self) -> impl Iterator<Item = &RawSection<'a>>
Iterate over all custom sections.