pub struct GlobalSection { /* private fields */ }
Expand description
An encoder for the global section.
Global sections are only supported for modules.
§Example
use wasm_encoder::{ConstExpr, Module, GlobalSection, GlobalType, Instruction, ValType};
let mut globals = GlobalSection::new();
globals.global(
GlobalType {
val_type: ValType::I32,
mutable: false,
shared: false,
},
&ConstExpr::i32_const(42),
);
let mut module = Module::new();
module.section(&globals);
let wasm_bytes = module.finish();
Implementations§
Source§impl GlobalSection
impl GlobalSection
Sourcepub fn global(
&mut self,
global_type: GlobalType,
init_expr: &ConstExpr,
) -> &mut Self
pub fn global( &mut self, global_type: GlobalType, init_expr: &ConstExpr, ) -> &mut Self
Define a global.
Trait Implementations§
Source§impl Clone for GlobalSection
impl Clone for GlobalSection
Source§fn clone(&self) -> GlobalSection
fn clone(&self) -> GlobalSection
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for GlobalSection
impl Debug for GlobalSection
Source§impl Default for GlobalSection
impl Default for GlobalSection
Source§fn default() -> GlobalSection
fn default() -> GlobalSection
Returns the “default value” for a type. Read more
Source§impl Encode for GlobalSection
impl Encode for GlobalSection
Auto Trait Implementations§
impl Freeze for GlobalSection
impl RefUnwindSafe for GlobalSection
impl Send for GlobalSection
impl Sync for GlobalSection
impl Unpin for GlobalSection
impl UnwindSafe for GlobalSection
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)