[][src]Struct walrus::Module

pub struct Module {
    pub imports: ModuleImports,
    pub tables: ModuleTables,
    pub types: ModuleTypes,
    pub funcs: ModuleFunctions,
    pub globals: ModuleGlobals,
    pub locals: ModuleLocals,
    pub exports: ModuleExports,
    pub memories: ModuleMemories,
    pub data: ModuleData,
    pub elements: ModuleElements,
    pub start: Option<FunctionId>,
    pub producers: ModuleProducers,
    pub customs: ModuleCustomSections,
    pub name: Option<String>,
    // some fields omitted
}

A wasm module.

Fields

imports: ModuleImportstables: ModuleTablestypes: ModuleTypesfuncs: ModuleFunctionsglobals: ModuleGlobalslocals: ModuleLocalsexports: ModuleExportsmemories: ModuleMemoriesdata: 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]

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]

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]

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]

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]

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]

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>(&mut self, path: P) -> Result<()> where
    P: AsRef<Path>, 
[src]

Emit this module into a .wasm file at the given path.

pub fn emit_wasm(&mut self) -> 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

impl Default for Module[src]

impl Debug for Module[src]

Auto Trait Implementations

impl Send for Module

impl Sync for Module

impl Unpin for Module

impl !UnwindSafe for Module

impl !RefUnwindSafe for Module

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = !

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]