[][src]Struct wasm_encoder::GlobalSection

pub struct GlobalSection { /* fields omitted */ }

An encoder for the global section.

Example

use wasm_encoder::{Module, GlobalSection, GlobalType, Instruction, ValType};

let mut globals = GlobalSection::new();
globals.global(
    GlobalType {
        val_type: ValType::I32,
        mutable: false,
    },
    Instruction::I32Const(42),
);

let mut module = Module::new();
module.section(&globals);

let wasm_bytes = module.finish();

Implementations

impl GlobalSection[src]

pub fn new() -> GlobalSection[src]

Create a new global section encoder.

pub fn global(
    &mut self,
    global_type: GlobalType,
    init_expr: Instruction<'_>
) -> &mut Self
[src]

Define a global.

Trait Implementations

impl Section for GlobalSection[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.