Struct wasm_encoder::ProducersSection
source · pub struct ProducersSection { /* private fields */ }
Expand description
An encoder for the producers custom section.
This section is a non-standard convention that is supported by many toolchains.
Example
use wasm_encoder::{ProducersSection, ProducersField, Module};
// Create a new producers section.
let mut field = ProducersField::new();
field.value("clang", "14.0.4");
field.value("rustc", "1.66.1 (90743e729 2023-01-10)");
let mut producers = ProducersSection::new();
producers.field("processed-by", &field);
// Add the producers section to a new Wasm module and get the encoded bytes.
let mut module = Module::new();
module.section(&producers);
let wasm_bytes = module.finish();
Implementations§
source§impl ProducersSection
impl ProducersSection
sourcepub fn field(&mut self, name: &str, values: &ProducersField) -> &mut Self
pub fn field(&mut self, name: &str, values: &ProducersField) -> &mut Self
Add a field to the section. The spec recommends names for this section are “language”, “processed-by”, and “sdk”. Each field in section must have a unique name.
Trait Implementations§
source§impl Clone for ProducersSection
impl Clone for ProducersSection
source§fn clone(&self) -> ProducersSection
fn clone(&self) -> ProducersSection
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 more