[][src]Struct wasm_encoder::ElementSection

pub struct ElementSection { /* fields omitted */ }

An encoder for the element section.

Example

use wasm_encoder::{
    Elements, ElementSection, Instruction, Module, TableSection, TableType,
    Limits, ValType,
};

let mut tables = TableSection::new();
tables.table(TableType {
    element_type: ValType::FuncRef,
    limits: Limits {
        min: 128,
        max: None,
    },
});

let mut elements = ElementSection::new();
let table_index = 0;
let offset = Instruction::I32Const(42);
let element_type = ValType::FuncRef;
let functions = Elements::Functions(&[
    // Function indices...
]);
elements.active(Some(table_index), offset, element_type, functions);

let mut module = Module::new();
module
    .section(&tables)
    .section(&elements);

let wasm_bytes = module.finish();

Implementations

impl ElementSection[src]

pub fn new() -> ElementSection[src]

Create a new element section encoder.

pub fn segment<'a>(&mut self, segment: ElementSegment<'a>) -> &mut Self[src]

Define an element segment.

pub fn active<'a>(
    &mut self,
    table_index: Option<u32>,
    offset: Instruction<'_>,
    element_type: ValType,
    elements: Elements<'a>
) -> &mut Self
[src]

Define an active element segment.

pub fn passive<'a>(
    &mut self,
    element_type: ValType,
    elements: Elements<'a>
) -> &mut Self
[src]

Encode a passive element segment.

Passive segments are part of the bulk memory proposal.

pub fn declared<'a>(
    &mut self,
    element_type: ValType,
    elements: Elements<'a>
) -> &mut Self
[src]

Encode a declared element segment.

Declared segments are part of the bulk memory proposal.

Trait Implementations

impl Section for ElementSection[src]

Auto Trait Implementations

Blanket Implementations

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

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

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

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 = Infallible

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.