Struct wasm_encoder::DataSection [−][src]
An encoder for the data section.
Example
use wasm_encoder::{ DataSection, Instruction, Limits, MemorySection, MemoryType, Module, }; let mut memory = MemorySection::new(); memory.memory(MemoryType { limits: Limits { min: 1, max: None, }, }); let mut data = DataSection::new(); let memory_index = 0; let offset = Instruction::I32Const(42); let segment_data = b"hello"; data.active(memory_index, offset, segment_data.iter().copied()); let mut module = Module::new(); module .section(&memory) .section(&data); let wasm_bytes = module.finish();
Implementations
impl DataSection
[src]
pub fn new() -> DataSection
[src]
Create a new data section encoder.
pub fn segment<D>(&mut self, segment: DataSegment<'_, D>) -> &mut Self where
D: IntoIterator<Item = u8>,
D::IntoIter: ExactSizeIterator,
[src]
D: IntoIterator<Item = u8>,
D::IntoIter: ExactSizeIterator,
Define an active data segment.
pub fn active<'a, D>(
&mut self,
memory_index: u32,
offset: Instruction<'a>,
data: D
) -> &mut Self where
D: IntoIterator<Item = u8>,
D::IntoIter: ExactSizeIterator,
[src]
&mut self,
memory_index: u32,
offset: Instruction<'a>,
data: D
) -> &mut Self where
D: IntoIterator<Item = u8>,
D::IntoIter: ExactSizeIterator,
Define an active data segment.
pub fn passive<'a, D>(&mut self, data: D) -> &mut Self where
D: IntoIterator<Item = u8>,
D::IntoIter: ExactSizeIterator,
[src]
D: IntoIterator<Item = u8>,
D::IntoIter: ExactSizeIterator,
Define a passive data segment.
Passive data segments are part of the bulk memory proposal.
Trait Implementations
impl Clone for DataSection
[src]
fn clone(&self) -> DataSection
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for DataSection
[src]
impl Section for DataSection
[src]
Auto Trait Implementations
impl RefUnwindSafe for DataSection
impl Send for DataSection
impl Sync for DataSection
impl Unpin for DataSection
impl UnwindSafe for DataSection
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,