Struct wasm_metadata::Producers
source · pub struct Producers(/* private fields */);
Expand description
A representation of a WebAssembly producers section.
Spec: https://github.com/WebAssembly/tool-conventions/blob/main/ProducersSection.md
Implementations§
source§impl Producers
impl Producers
sourcepub fn from_wasm(bytes: &[u8]) -> Result<Option<Self>>
pub fn from_wasm(bytes: &[u8]) -> Result<Option<Self>>
Read the producers section from a Wasm binary. Supports both core Modules and Components. In the component case, only returns the producers section in the outer component, ignoring all interior components and modules.
sourcepub fn from_bytes(bytes: &[u8], offset: usize) -> Result<Self>
pub fn from_bytes(bytes: &[u8], offset: usize) -> Result<Self>
Read the producers section from a Wasm binary.
sourcepub fn add(&mut self, field: &str, name: &str, version: &str)
pub fn add(&mut self, field: &str, name: &str, version: &str)
Add a name & version value to a field.
The spec says expected field names are “language”, “processed-by”, and “sdk”. The version value should be left blank for languages.
sourcepub fn merge(&mut self, other: &Self)
pub fn merge(&mut self, other: &Self)
Add all values found in another Producers
section. Values in other
take
precedence.
sourcepub fn get<'a>(&'a self, field: &str) -> Option<ProducersField<'a>>
pub fn get<'a>(&'a self, field: &str) -> Option<ProducersField<'a>>
Get the contents of a field
sourcepub fn iter<'a>(
&'a self
) -> impl Iterator<Item = (&'a String, ProducersField<'a>)> + 'a
pub fn iter<'a>( &'a self ) -> impl Iterator<Item = (&'a String, ProducersField<'a>)> + 'a
Iterate through all fields
sourcepub fn raw_custom_section(&self) -> Vec<u8>
pub fn raw_custom_section(&self) -> Vec<u8>
Serialize into the raw bytes of a wasm custom section.