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,
ValType, ConstExpr
};
let mut tables = TableSection::new();
tables.table(TableType {
element_type: ValType::FuncRef,
minimum: 128,
maximum: None,
});
let mut elements = ElementSection::new();
let table_index = 0;
let offset = ConstExpr::i32_const(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
sourceimpl 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,
element_type: ValType,
elements: Elements<'_>
) -> &mut Self
pub fn active(
&mut self,
table_index: Option<u32>,
offset: &ConstExpr,
element_type: ValType,
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,
element_type: ValType,
elements: Elements<'a>
) -> &mut Self
pub fn passive<'a>(
&mut self,
element_type: ValType,
elements: Elements<'a>
) -> &mut Self
Encode a passive element segment.
Passive segments are part of the bulk memory proposal.
Trait Implementations
sourceimpl Clone for ElementSection
impl Clone for ElementSection
sourcefn clone(&self) -> ElementSection
fn clone(&self) -> ElementSection
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for ElementSection
impl Debug for ElementSection
sourceimpl Default for ElementSection
impl Default for ElementSection
sourcefn default() -> ElementSection
fn default() -> ElementSection
Returns the “default value” for a type. Read more
sourceimpl 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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more