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

Creates a new blank name custom section.

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.

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).

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).

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).

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).

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).

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).

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).

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).

Appends a subsection for the names of all data in this wasm module.

This section should come after the element name subsection (if present).

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Encode the type into the given byte sink.

Gets the section identifier for this section.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.