Struct wasm_encoder::ElementSection
source · pub struct ElementSection { /* private fields */ }
Expand description
An encoder for the element section.
Element sections are only supported for modules.
Example
use wasm_encoder::{
Elements, ElementSection, Module, TableSection, TableType,
RefType, ConstExpr
};
let mut tables = TableSection::new();
tables.table(TableType {
element_type: RefType::FUNCREF,
minimum: 128,
maximum: None,
});
let mut elements = ElementSection::new();
let table_index = 0;
let offset = ConstExpr::i32_const(42);
let functions = Elements::Functions(&[
// Function indices...
]);
elements.active(Some(table_index), &offset, functions);
let mut module = Module::new();
module
.section(&tables)
.section(&elements);
let wasm_bytes = module.finish();
Implementations§
source§impl ElementSection
impl ElementSection
sourcepub fn segment<'a>(&mut self, segment: ElementSegment<'a>) -> &mut Self
pub fn segment<'a>(&mut self, segment: ElementSegment<'a>) -> &mut Self
Define an element segment.
sourcepub fn active(
&mut self,
table_index: Option<u32>,
offset: &ConstExpr,
elements: Elements<'_>
) -> &mut Self
pub fn active( &mut self, table_index: Option<u32>, offset: &ConstExpr, elements: Elements<'_> ) -> &mut Self
Define an active element segment.
Active
element specifying a None
table forces the MVP encoding and refers to the 0th
table holding funcref
s. Non-None
tables use the encoding introduced with the bulk
memory proposal and can refer to tables with any valid reference type.
sourcepub fn passive<'a>(&mut self, elements: Elements<'a>) -> &mut Self
pub fn passive<'a>(&mut self, elements: Elements<'a>) -> &mut Self
Encode a passive element segment.
Passive segments are part of the bulk memory proposal.
Trait Implementations§
source§impl Clone for ElementSection
impl Clone for ElementSection
source§fn clone(&self) -> ElementSection
fn clone(&self) -> ElementSection
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for ElementSection
impl Debug for ElementSection
source§impl Default for ElementSection
impl Default for ElementSection
source§fn default() -> ElementSection
fn default() -> ElementSection
Returns the “default value” for a type. Read more
source§impl Encode for ElementSection
impl Encode for ElementSection
Auto Trait Implementations§
impl RefUnwindSafe for ElementSection
impl Send for ElementSection
impl Sync for ElementSection
impl Unpin for ElementSection
impl UnwindSafe for ElementSection
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more