Struct wasm_encoder::NameSection
source · [−]pub struct NameSection { /* private fields */ }
Expand description
An encoder for the custom name
section.
Example
use wasm_encoder::{Module, NameSection, NameMap};
let mut names = NameSection::new();
names.module("the module name");
let mut function_names = NameMap::new();
function_names.append(0, "name of function 0");
function_names.append(1, "a better function");
function_names.append(3, "the best function");
names.functions(&function_names);
let mut module = Module::new();
module.section(&names);
let wasm_bytes = module.finish();
Implementations
sourceimpl NameSection
impl NameSection
sourcepub fn module(&mut self, name: &str)
pub fn module(&mut self, name: &str)
Appends a module name subsection to this section.
This will indicate that the name of the entire module should be the
name
specified. Note that this should be encoded first before other
subsections.
sourcepub fn functions(&mut self, names: &NameMap)
pub fn functions(&mut self, names: &NameMap)
Appends a subsection for the names of all functions in this wasm module.
Function names are declared in the names
map provided where the index
in the map corresponds to the wasm index of the function. This section
should come after the module name subsection (if present) and before the
locals subsection (if present).
sourcepub fn locals(&mut self, names: &IndirectNameMap)
pub fn locals(&mut self, names: &IndirectNameMap)
Appends a subsection for the names of locals within functions in the wasm module.
This section should come after the function name subsection (if present) and before the labels subsection (if present).
sourcepub fn labels(&mut self, names: &IndirectNameMap)
pub fn labels(&mut self, names: &IndirectNameMap)
Appends a subsection for the names of labels within functions in the wasm module.
This section should come after the local name subsection (if present) and before the type subsection (if present).
sourcepub fn types(&mut self, names: &NameMap)
pub fn types(&mut self, names: &NameMap)
Appends a subsection for the names of all types in this wasm module.
This section should come after the label name subsection (if present) and before the table subsection (if present).
sourcepub fn tables(&mut self, names: &NameMap)
pub fn tables(&mut self, names: &NameMap)
Appends a subsection for the names of all tables in this wasm module.
This section should come after the type name subsection (if present) and before the memory subsection (if present).
sourcepub fn memories(&mut self, names: &NameMap)
pub fn memories(&mut self, names: &NameMap)
Appends a subsection for the names of all memories in this wasm module.
This section should come after the table name subsection (if present) and before the global subsection (if present).
sourcepub fn globals(&mut self, names: &NameMap)
pub fn globals(&mut self, names: &NameMap)
Appends a subsection for the names of all globals in this wasm module.
This section should come after the memory name subsection (if present) and before the element subsection (if present).
Trait Implementations
sourceimpl Clone for NameSection
impl Clone for NameSection
sourcefn clone(&self) -> NameSection
fn clone(&self) -> NameSection
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for NameSection
impl Debug for NameSection
sourceimpl Default for NameSection
impl Default for NameSection
sourcefn default() -> NameSection
fn default() -> NameSection
Returns the “default value” for a type. Read more
sourceimpl Encode for NameSection
impl Encode for NameSection
Auto Trait Implementations
impl RefUnwindSafe for NameSection
impl Send for NameSection
impl Sync for NameSection
impl Unpin for NameSection
impl UnwindSafe for NameSection
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more