Struct wasm_encoder::CodeSection [−][src]
An encoder for the code section.
Example
use wasm_encoder::{ CodeSection, Function, FunctionSection, Instruction, Module, TypeSection, ValType }; let mut types = TypeSection::new(); types.function(vec![], vec![ValType::I32]); let mut functions = FunctionSection::new(); let type_index = 0; functions.function(type_index); let locals = vec![]; let mut func = Function::new(locals); func.instruction(Instruction::I32Const(42)); let mut code = CodeSection::new(); code.function(&func); let mut module = Module::new(); module .section(&types) .section(&functions) .section(&code); let wasm_bytes = module.finish();
Implementations
impl CodeSection
[src]
pub fn new() -> CodeSection
[src]
Create a new code section encoder.
pub fn function(&mut self, func: &Function) -> &mut Self
[src]
Write a function body into this code section.
Trait Implementations
impl Clone for CodeSection
[src]
fn clone(&self) -> CodeSection
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for CodeSection
[src]
impl Section for CodeSection
[src]
Auto Trait Implementations
impl RefUnwindSafe for CodeSection
impl Send for CodeSection
impl Sync for CodeSection
impl Unpin for CodeSection
impl UnwindSafe for CodeSection
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>,