Struct wasm_encoder::ElementSection
source · [−]pub struct ElementSection { /* private fields */ }
Expand description
An encoder for the element section.
Example
use wasm_encoder::{
Elements, ElementSection, Instruction, Module, TableSection, TableType,
ValType,
};
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 = 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
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: &Instruction<'_>,
element_type: ValType,
elements: Elements<'_>
) -> &mut Self
pub fn active(
&mut self,
table_index: Option<u32>,
offset: &Instruction<'_>,
element_type: ValType,
elements: Elements<'_>
) -> &mut Self
Define an active element segment.
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
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 · sourcepub fn borrow_mut(&mut self) -> &mut T
pub 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.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more