# [−] [src] Struct parity_wasm::elements::Module

    pub struct Module { /* fields omitted */ }

WebAssembly module

## Methods

### `impl Module` [src]

#### `pub fn new(sections: Vec<Section>) -> Self` [src]

New module with sections

#### `pub fn from_bytes<T: AsRef<[u8]>>(input: T) -> Result<Self, Error>` [src]

Construct a module from a slice.

#### `pub fn to_bytes(self) -> Result<Vec<u8>, Error>` [src]

Serialize a module to a vector.

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

### Important traits for Vec<u8>

`impl Write for Vec<u8>`
`pub fn into_sections(self) -> Vec<Section>` [src]

Destructure the module, yielding sections

#### `pub fn version(&self) -> u32` [src]

Version of module.

####
ⓘImportant traits for &'_ [ u8 ]

### Important traits for &'_ [ u8 ]

`impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]`
`pub fn sections(&self) -> &[Section]` [src]

Sections list.

Each known section is optional and may appear at most once.

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

### Important traits for Vec<u8>

`impl Write for Vec<u8>`
`pub fn sections_mut(&mut self) -> &mut Vec<Section>` [src]

Sections list (mutable).

Each known section is optional and may appear at most once.

#### `pub fn insert_section(&mut self, section: Section) -> Result<(), Error>` [src]

Insert a section, in the correct section ordering. This will fail with an error, if the section can only appear once.

#### `pub fn code_section(&self) -> Option<&CodeSection>` [src]

Code section reference, if any.

#### `pub fn code_section_mut(&mut self) -> Option<&mut CodeSection>` [src]

Code section mutable reference, if any.

#### `pub fn type_section(&self) -> Option<&TypeSection>` [src]

Types section reference, if any.

#### `pub fn type_section_mut(&mut self) -> Option<&mut TypeSection>` [src]

Types section mutable reference, if any.

#### `pub fn import_section(&self) -> Option<&ImportSection>` [src]

Imports section reference, if any.

#### `pub fn import_section_mut(&mut self) -> Option<&mut ImportSection>` [src]

Imports section mutable reference, if any.

#### `pub fn global_section(&self) -> Option<&GlobalSection>` [src]

Globals section reference, if any.

#### `pub fn global_section_mut(&mut self) -> Option<&mut GlobalSection>` [src]

Globals section mutable reference, if any.

#### `pub fn export_section(&self) -> Option<&ExportSection>` [src]

Exports section reference, if any.

#### `pub fn export_section_mut(&mut self) -> Option<&mut ExportSection>` [src]

Exports section mutable reference, if any.

#### `pub fn table_section(&self) -> Option<&TableSection>` [src]

Table section reference, if any.

#### `pub fn table_section_mut(&mut self) -> Option<&mut TableSection>` [src]

Table section mutable reference, if any.

#### `pub fn data_section(&self) -> Option<&DataSection>` [src]

Data section reference, if any.

#### `pub fn data_section_mut(&mut self) -> Option<&mut DataSection>` [src]

Data section mutable reference, if any.

#### `pub fn elements_section(&self) -> Option<&ElementSection>` [src]

Element section reference, if any.

#### `pub fn elements_section_mut(&mut self) -> Option<&mut ElementSection>` [src]

Element section mutable reference, if any.

#### `pub fn memory_section(&self) -> Option<&MemorySection>` [src]

Memory section reference, if any.

#### `pub fn memory_section_mut(&mut self) -> Option<&mut MemorySection>` [src]

Memory section mutable reference, if any.

#### `pub fn function_section(&self) -> Option<&FunctionSection>` [src]

Functions signatures section reference, if any.

#### `pub fn function_section_mut(&mut self) -> Option<&mut FunctionSection>` [src]

Functions signatures section mutable reference, if any.

#### `pub fn start_section(&self) -> Option<u32>` [src]

Start section, if any.

#### `pub fn set_start_section(&mut self, new_start: u32)` [src]

Changes the module's start section.

#### `pub fn clear_start_section(&mut self)` [src]

Removes the module's start section.

#### `pub fn custom_sections(&self) -> impl Iterator<Item = &CustomSection>` [src]

Returns an iterator over the module's custom sections

#### `pub fn set_custom_section(&mut self, name: impl Into<String>, payload: Vec<u8>)` [src]

Sets the payload associated with the given custom section, or adds a new custom section, as appropriate.

#### `pub fn clear_custom_section(
&mut self,
name: impl AsRef<str>
) -> Option<CustomSection>` [src]

Removes the given custom section, if it exists. Returns the removed section if it existed, or None otherwise.

#### `pub fn has_names_section(&self) -> bool` [src]

True if a name section is present.

NOTE: this can return true even if the section was not parsed, hence `names_section()` may return `None` even if this returns `true`

#### `pub fn names_section(&self) -> Option<&NameSection>` [src]

Functions signatures section reference, if any.

NOTE: name section is not parsed by default so `names_section` could return None even if name section exists. Call `parse_names` to parse name section

#### `pub fn names_section_mut(&mut self) -> Option<&mut NameSection>` [src]

Functions signatures section mutable reference, if any.

NOTE: name section is not parsed by default so `names_section` could return None even if name section exists. Call `parse_names` to parse name section

#### `pub fn parse_names(self) -> Result<Self, (Vec<(usize, Error)>, Self)>` [src]

Try to parse name section in place.

Corresponding custom section with proper header will convert to name sections If some of them will fail to be decoded, Err variant is returned with the list of (index, Error) tuples of failed sections.

#### `pub fn parse_reloc(self) -> Result<Self, (Vec<(usize, Error)>, Self)>` [src]

Try to parse reloc section in place.

Corresponding custom section with proper header will convert to reloc sections If some of them will fail to be decoded, Err variant is returned with the list of (index, Error) tuples of failed sections.

#### `pub fn import_count(&self, count_type: ImportCountType) -> usize` [src]

Count imports by provided type.

#### `pub fn functions_space(&self) -> usize` [src]

Query functions space.

#### `pub fn globals_space(&self) -> usize` [src]

Query globals space.

#### `pub fn table_space(&self) -> usize` [src]

Query table space.

#### `pub fn memory_space(&self) -> usize` [src]

Query memory space.

## Trait Implementations

### `impl Deserialize for Module` [src]

#### `type Error = Error`

Serialization error produced by deserialization routine.

#### `fn deserialize<R: Read>(reader: &mut R) -> Result<Self, Self::Error>` [src]

Deserialize type from serial i/o

### `impl Serialize for Module` [src]

#### `type Error = Error`

Serialization error produced by serialization routine.

#### `fn serialize<W: Write>(self, w: &mut W) -> Result<(), Self::Error>` [src]

Serialize type to serial i/o

### `impl Clone for Module` [src]

#### `fn clone(&self) -> Module` [src]

Returns a copy of the value. Read more

#### `fn clone_from(&mut self, source: &Self)`1.0.0 [src]

Performs copy-assignment from `source`. Read more

### `impl Default for Module` [src]

#### `fn default() -> Self` [src]

Returns the "default value" for a type. Read more

### `impl PartialEq<Module> for Module` [src]

#### `fn eq(&self, other: &Module) -> bool` [src]

This method tests for `self` and `other` values to be equal, and is used by `==`. Read more

#### `fn ne(&self, other: &Module) -> bool` [src]

This method tests for `!=`.

### `impl Debug for Module` [src]

#### `fn fmt(&self, f: &mut Formatter) -> Result` [src]

Formats the value using the given formatter. Read more

## 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, 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> ToOwned for T where
T: Clone,` [src]

#### `type Owned = T`

The resulting type after obtaining ownership.

#### `fn to_owned(&self) -> T` [src]

Creates owned data from borrowed data, usually by cloning. Read more

#### `fn clone_into(&self, target: &mut T)` [src]

🔬 This is a nightly-only experimental API. (`toowned_clone_into`)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

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