[−][src]Struct walrus::Module
A wasm module.
Fields
imports: ModuleImports
tables: ModuleTables
types: ModuleTypes
funcs: ModuleFunctions
globals: ModuleGlobals
locals: ModuleLocals
exports: ModuleExports
memories: ModuleMemories
data: ModuleData
Registration of passive data segments, if any
elements: ModuleElements
Registration of passive element segments, if any
start: Option<FunctionId>
The start
function, if any
producers: ModuleProducers
Representation of the eventual custom section, producers
customs: ModuleCustomSections
Custom sections found in this module.
name: Option<String>
The name of this module, used for debugging purposes in the name
custom section.
Methods
impl Module
[src]
pub fn write_graphviz_dot(&self, path: impl AsRef<Path>) -> Result<()>
[src]
Generate a GraphViz Dot file for this module, showing the relationship between various structures in the module and its instructions.
Example
First, generate a .dot
file with this method:
let my_module: walrus::Module = get_module_from_somewhere(); my_module.write_graphviz_dot("my_module.dot")?;
Second, use the dot
command-line tool to render an SVG (or PNG,
etc...):
dot my_module.dot \ # Provide our generated `.dot`.
-T svg \ # Generate an SVG image.
-o my_module.svg # Write to this output file.
impl Module
[src]
pub fn add_import_func(
&mut self,
module: &str,
name: &str,
ty: TypeId
) -> (FunctionId, ImportId)
[src]
&mut self,
module: &str,
name: &str,
ty: TypeId
) -> (FunctionId, ImportId)
Add an imported function to this module
pub fn add_import_memory(
&mut self,
module: &str,
name: &str,
shared: bool,
initial: u32,
maximum: Option<u32>
) -> (MemoryId, ImportId)
[src]
&mut self,
module: &str,
name: &str,
shared: bool,
initial: u32,
maximum: Option<u32>
) -> (MemoryId, ImportId)
Add an imported memory to this module
pub fn add_import_table(
&mut self,
module: &str,
name: &str,
initial: u32,
max: Option<u32>,
kind: TableKind
) -> (TableId, ImportId)
[src]
&mut self,
module: &str,
name: &str,
initial: u32,
max: Option<u32>,
kind: TableKind
) -> (TableId, ImportId)
Add an imported table to this module
pub fn add_import_global(
&mut self,
module: &str,
name: &str,
ty: ValType,
mutable: bool
) -> (GlobalId, ImportId)
[src]
&mut self,
module: &str,
name: &str,
ty: ValType,
mutable: bool
) -> (GlobalId, ImportId)
Add an imported global to this module
impl Module
[src]
pub fn with_config(config: ModuleConfig) -> Self
[src]
Create a default, empty module that uses the given configuration.
pub fn from_file<P>(path: P) -> Result<Module> where
P: AsRef<Path>,
[src]
P: AsRef<Path>,
Construct a new module from the given path with the default configuration.
pub fn from_file_with_config<P>(
path: P,
config: &ModuleConfig
) -> Result<Module> where
P: AsRef<Path>,
[src]
path: P,
config: &ModuleConfig
) -> Result<Module> where
P: AsRef<Path>,
Construct a new module from the given path and configuration.
pub fn from_buffer(wasm: &[u8]) -> Result<Module>
[src]
Construct a new module from the in-memory wasm buffer with the default configuration.
pub fn emit_wasm_file<P>(&self, path: P) -> Result<()> where
P: AsRef<Path>,
[src]
P: AsRef<Path>,
Emit this module into a .wasm
file at the given path.
pub fn emit_wasm(&self) -> Result<Vec<u8>>
[src]
Emit this module into an in-memory wasm buffer.
pub fn functions(&self) -> impl Iterator<Item = &Function>
[src]
Returns an iterator over all functions in this module
Trait Implementations
Auto Trait Implementations
impl Sync for Module
impl Send for Module
impl Unpin for Module
impl !RefUnwindSafe for Module
impl !UnwindSafe for Module
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,