[][src]Struct wasm_encoder::CodeSection

pub struct CodeSection { /* fields omitted */ }

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 Section for CodeSection[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.