[−][src]Struct wasm_encoder::Function
An encoder for a function body within the code section.
Example
use wasm_encoder::{CodeSection, Function, Instruction}; // Define the function body for: // // (func (param i32 i32) (result i32) // local.get 0 // local.get 1 // i32.add) let locals = vec![]; let mut func = Function::new(locals); func.instruction(Instruction::LocalGet(0)); func.instruction(Instruction::LocalGet(1)); func.instruction(Instruction::I32Add); // Add our function to the code section. let mut code = CodeSection::new(); code.function(&func);
Implementations
impl Function
[src][−]
pub fn new<L>(locals: L) -> Self where
L: IntoIterator<Item = (u32, ValType)>,
L::IntoIter: ExactSizeIterator,
[src][−]
L: IntoIterator<Item = (u32, ValType)>,
L::IntoIter: ExactSizeIterator,
Create a new function body with the given locals.
pub fn instruction(&mut self, instruction: Instruction<'_>) -> &mut Self
[src][−]
Write an instruction into this function body.
pub fn raw<B>(&mut self, bytes: B) -> &mut Self where
B: IntoIterator<Item = u8>,
[src][−]
B: IntoIterator<Item = u8>,
Add raw bytes to this function's body.
Auto Trait Implementations
impl RefUnwindSafe for Function
[src]
impl Send for Function
[src]
impl Sync for Function
[src]
impl Unpin for Function
[src]
impl UnwindSafe for Function
[src]
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,
impl<T> From<T> for T
[src][+]
impl<T, U> Into<U> for T where
U: From<T>,
[src][+]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src][+]
U: Into<T>,
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src][+]
U: TryFrom<T>,