Struct wasm_encoder::Function [−][src]
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.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Function
impl Send for Function
impl Sync for Function
impl Unpin for Function
impl UnwindSafe for Function
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>,