pub struct Module { /* private fields */ }Expand description
A compiled bytecode module.
Instructions are decoded lazily via decode_step.
Cold data (strings, symbols, types) is accessed through view methods.
Implementations§
Source§impl Module
impl Module
Sourcepub fn from_aligned(vec: AlignedVec) -> Result<Self, ModuleError>
pub fn from_aligned(vec: AlignedVec) -> Result<Self, ModuleError>
Load a module from an aligned vector (compiler output).
This is the primary constructor for bytecode produced by the compiler.
Sourcepub fn from_static(bytes: &'static [u8]) -> Result<Self, ModuleError>
pub fn from_static(bytes: &'static [u8]) -> Result<Self, ModuleError>
Sourcepub fn from_path(path: impl AsRef<Path>) -> Result<Self, ModuleError>
pub fn from_path(path: impl AsRef<Path>) -> Result<Self, ModuleError>
Load a module from a file path.
Reads the file into 64-byte aligned storage.
Sourcepub fn load(bytes: &[u8]) -> Result<Self, ModuleError>
pub fn load(bytes: &[u8]) -> Result<Self, ModuleError>
Load a module from arbitrary bytes (copies into aligned storage).
Use this for bytes from unknown sources (network, etc.). Always copies.
Sourcepub fn from_bytes(bytes: Vec<u8>) -> Result<Self, ModuleError>
👎Deprecated since 0.1.0: use Module::from_aligned for AlignedVec or Module::load for copying
pub fn from_bytes(bytes: Vec<u8>) -> Result<Self, ModuleError>
Module::from_aligned for AlignedVec or Module::load for copyingLoad a module from owned bytes (copies into aligned storage).
Sourcepub fn offsets(&self) -> &SectionOffsets
pub fn offsets(&self) -> &SectionOffsets
Get the computed section offsets.
Sourcepub fn decode_step(&self, step: u16) -> Instruction<'_>
pub fn decode_step(&self, step: u16) -> Instruction<'_>
Decode an instruction at the given step index.
Sourcepub fn strings(&self) -> StringsView<'_>
pub fn strings(&self) -> StringsView<'_>
Get a view into the string table.
Sourcepub fn node_types(&self) -> SymbolsView<'_, NodeSymbol>
pub fn node_types(&self) -> SymbolsView<'_, NodeSymbol>
Get a view into the node type symbols.
Sourcepub fn node_fields(&self) -> SymbolsView<'_, FieldSymbol>
pub fn node_fields(&self) -> SymbolsView<'_, FieldSymbol>
Get a view into the node field symbols.
Sourcepub fn trivia(&self) -> TriviaView<'_>
pub fn trivia(&self) -> TriviaView<'_>
Get a view into the trivia entries.
Sourcepub fn entrypoints(&self) -> EntrypointsView<'_>
pub fn entrypoints(&self) -> EntrypointsView<'_>
Get a view into the entrypoints.