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§
Source§impl 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 this 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 this 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).
Sourcepub fn elements(&mut self, names: &NameMap)
pub fn elements(&mut self, names: &NameMap)
Appends a subsection for the names of all elements in this wasm module.
This section should come after the global name subsection (if present) and before the data subsection (if present).
Sourcepub fn data(&mut self, names: &NameMap)
pub fn data(&mut self, names: &NameMap)
Appends a subsection for the names of all data in this wasm module.
This section should come after the element name subsection (if present) and before the field subsection (if present).
Sourcepub fn tag(&mut self, names: &NameMap)
pub fn tag(&mut self, names: &NameMap)
Appends a subsection for the names of all tags in this wasm module.
This section should come after the data name subsection (if present).
Sourcepub fn fields(&mut self, names: &IndirectNameMap)
pub fn fields(&mut self, names: &IndirectNameMap)
Appends a subsection for the names of fields within types in this wasm module.
This section should come after the data name subsection (if present) and before the tag subsection (if present).
Appends a subsection for the names of all tags in this wasm module.
This section should come after the field name subsection (if present).
Sourcepub fn raw(&mut self, id: u8, data: &[u8])
pub fn raw(&mut self, id: u8, data: &[u8])
Appends a raw subsection with the given id and data.
Sourcepub fn as_custom<'a>(&'a self) -> CustomSection<'a>
pub fn as_custom<'a>(&'a self) -> CustomSection<'a>
View the encoded section as a CustomSection.
Trait Implementations§
Source§impl Clone for NameSection
impl Clone for NameSection
Source§fn clone(&self) -> NameSection
fn clone(&self) -> NameSection
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for NameSection
impl Debug for NameSection
Source§impl Default for NameSection
impl Default for NameSection
Source§fn default() -> NameSection
fn default() -> NameSection
Source§impl Encode for NameSection
impl Encode for NameSection
Auto Trait Implementations§
impl Freeze for NameSection
impl RefUnwindSafe for NameSection
impl Send for NameSection
impl Sync for NameSection
impl Unpin for NameSection
impl UnwindSafe for NameSection
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
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)
clone_to_uninit
)