# [−] [src] Struct parity_wasm::builder::ModuleBuilder

    pub struct ModuleBuilder<F = Identity> { /* fields omitted */ }

Module builder

## Methods

### `impl ModuleBuilder` [src]

#### `pub fn new() -> Self` [src]

New empty module builder

### `impl<F> ModuleBuilder<F> where
F: Invoke<Module>,` [src]

#### `pub fn with_callback(callback: F) -> Self` [src]

New module builder with bound callback

#### `pub fn with_module(self, module: Module) -> Self` [src]

Builder from raw module

#### `pub fn with_sections<I>(self, sections: I) -> Self where
I: IntoIterator<Item = Section>,` [src]

Fill module with sections from iterator

#### `pub fn with_section(self, section: Section) -> Self` [src]

Add additional section

#### `pub fn with_signatures(self, bindings: Vec<Signature>) -> Self` [src]

Binds to the type section, creates additional types when required

#### `pub fn push_function(&mut self, func: FunctionDefinition) -> CodeLocation` [src]

Push stand-alone function definition, creating sections, signature and code blocks in corresponding sections. `FunctionDefinition` can be build using `builder::function` builder

#### `pub fn push_memory(&mut self, memory: MemoryDefinition) -> u32` [src]

Push linear memory region

#### `pub fn push_table(&mut self, table: TableDefinition) -> u32` [src]

Push table

#### `pub fn push_signature(&mut self, signature: Signature) -> u32` [src]

Push one function signature, returning it's calling index. Can create corresponding type in type section.

####
ⓘImportant traits for Vec<u8>

### Important traits for Vec<u8>

`impl Write for Vec<u8>`
`pub fn push_signatures(&mut self, signatures: Vec<Signature>) -> Vec<u32>` [src]

Push signatures in the module, returning corresponding indices of pushed signatures

#### `pub fn push_import(&mut self, import: ImportEntry) -> u32` [src]

Push import entry to module. Note that this does not update calling indices in function bodies.

#### `pub fn push_export(&mut self, export: ExportEntry) -> u32` [src]

Push export entry to module.

#### `pub fn function(self) -> FunctionBuilder<Self>` [src]

Add new function using dedicated builder

#### `pub fn memory(self) -> MemoryBuilder<Self>` [src]

Add new linear memory using dedicated builder

#### `pub fn table(self) -> TableBuilder<Self>` [src]

Add new table using dedicated builder

#### `pub fn functions(self) -> SignaturesBuilder<Self>` [src]

Define functions section

#### `pub fn with_export(self, entry: ExportEntry) -> Self` [src]

With inserted export entry

#### `pub fn with_import(self, entry: ImportEntry) -> Self` [src]

With inserted import entry

#### `pub fn import(self) -> ImportBuilder<Self>` [src]

Import entry builder

# Examples

    use parity_wasm::builder::module;

    let module = module()
       .import()
           .module("env")
           .field("memory")
           .external().memory(256, Some(256))
           .build()
       .build();

    assert_eq!(module.import_section().expect("import section to exist").entries().len(), 1);

#### `pub fn with_global(self, global: GlobalEntry) -> Self` [src]

With global variable

#### `pub fn with_table(self, table: TableType) -> Self` [src]

With table

#### `pub fn export(self) -> ExportBuilder<Self>` [src]

Export entry builder

# Examples

    use parity_wasm::builder::module;
    use parity_wasm::elements::Instruction::*;

    let module = module()
       .global()
            .value_type().i32()
            .init_expr(I32Const(0))
            .build()
       .export()
           .field("_zero")
           .internal().global(0)
           .build()
       .build();

    assert_eq!(module.export_section().expect("export section to exist").entries().len(), 1);

#### `pub fn global(self) -> GlobalBuilder<Self>` [src]

Glboal entry builder

# Examples

    use parity_wasm::builder::module;
    use parity_wasm::elements::Instruction::*;

    let module = module()
       .global()
            .value_type().i32()
            .init_expr(I32Const(0))
            .build()
       .build();

    assert_eq!(module.global_section().expect("global section to exist").entries().len(), 1);

#### `pub fn with_data_segment(self, segment: DataSegment) -> Self` [src]

Add data segment to the builder

#### `pub fn data(self) -> DataSegmentBuilder<Self>` [src]

Data entry builder

#### `pub fn build(self) -> F::Result` [src]

Build module (final step)

## Auto Trait Implementations

### `impl<F> Send for ModuleBuilder<F> where
F: Send,`

### `impl<F> Sync for ModuleBuilder<F> where
F: Sync,`

### `impl<F> Unpin for ModuleBuilder<F> where
F: Unpin,`

### `impl<F> UnwindSafe for ModuleBuilder<F> where
F: UnwindSafe,`

### `impl<F> RefUnwindSafe for ModuleBuilder<F> where
F: RefUnwindSafe,`

## Blanket Implementations

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

#### `fn into(self) -> U` [src]

Performs the conversion.

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

#### `fn from(t: T) -> T` [src]

Performs the conversion.

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

#### `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]

Performs the conversion.

### `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.

#### `fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>` [src]

Performs the conversion.

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

####
ⓘImportant traits for &'_ mut R

### Important traits for &'_ mut R

`impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<'_, F> Future for &'_ mut F where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;`
`fn borrow(&self) -> &T` [src]

Immutably borrows from an owned value. Read more

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

####
ⓘImportant traits for &'_ mut R

### Important traits for &'_ mut R

`impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<'_, F> Future for &'_ mut F where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;`
`fn borrow_mut(&mut self) -> &mut T` [src]

Mutably borrows from an owned value. Read more

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

#### `fn type_id(&self) -> TypeId` [src]

Gets the `TypeId` of `self`. Read more

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g., `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g., `vec -> usize` or `* -> vec`)

Search multiple things at once by splitting your query with comma (e.g., `str,u8` or `String,struct:Vec,test`)