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

source

pub fn empty() -> Self

Creates an empty producers section

source

pub fn is_empty(&self) -> bool

Indicates if section is empty

source

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.

source

pub fn from_bytes(bytes: &[u8], offset: usize) -> Result<Self>

Read the producers section from a Wasm binary.

source

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.

source

pub fn merge(&mut self, other: &Self)

Add all values found in another Producers section. Values in other take precedence.

source

pub fn get<'a>(&'a self, field: &str) -> Option<ProducersField<'a>>

Get the contents of a field

source

pub fn iter<'a>( &'a self ) -> impl Iterator<Item = (&'a String, ProducersField<'a>)> + 'a

Iterate through all fields

source

pub fn raw_custom_section(&self) -> Vec<u8>

Serialize into the raw bytes of a wasm custom section.

source

pub fn add_to_wasm(&self, input: &[u8]) -> Result<Vec<u8>>

Merge into an existing wasm module. Rewrites the module with this producers section merged into its existing one, or adds this producers section if none is present.

Trait Implementations§

source§

impl Debug for Producers

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Producers

source§

fn default() -> Self

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

impl Display for Producers

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Serialize for Producers

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.