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.