pub struct ComponentTypeSection { /* private fields */ }
Expand description
An encoder for the type section of WebAssembly components.
§Example
use wasm_encoder::{Component, ComponentTypeSection, PrimitiveValType};
let mut types = ComponentTypeSection::new();
// Define a function type of `[string, string] -> string`.
types
.function()
.params(
[
("a", PrimitiveValType::String),
("b", PrimitiveValType::String)
]
)
.result(Some(PrimitiveValType::String.into()));
let mut component = Component::new();
component.section(&types);
let bytes = component.finish();
Implementations§
Source§impl ComponentTypeSection
impl ComponentTypeSection
Sourcepub fn new() -> Self
Available on crate feature component-model
only.
pub fn new() -> Self
component-model
only.Create a new component type section encoder.
Sourcepub fn len(&self) -> u32
Available on crate feature component-model
only.
pub fn len(&self) -> u32
component-model
only.The number of types in the section.
Sourcepub fn is_empty(&self) -> bool
Available on crate feature component-model
only.
pub fn is_empty(&self) -> bool
component-model
only.Determines if the section is empty.
Sourcepub fn ty(&mut self) -> ComponentTypeEncoder<'_>
Available on crate feature component-model
only.
pub fn ty(&mut self) -> ComponentTypeEncoder<'_>
component-model
only.Encode a type into this section.
The returned encoder must be finished before adding another type.
Sourcepub fn component(&mut self, ty: &ComponentType) -> &mut Self
Available on crate feature component-model
only.
pub fn component(&mut self, ty: &ComponentType) -> &mut Self
component-model
only.Define a component type in this type section.
Sourcepub fn instance(&mut self, ty: &InstanceType) -> &mut Self
Available on crate feature component-model
only.
pub fn instance(&mut self, ty: &InstanceType) -> &mut Self
component-model
only.Define an instance type in this type section.
Sourcepub fn function(&mut self) -> ComponentFuncTypeEncoder<'_>
Available on crate feature component-model
only.
pub fn function(&mut self) -> ComponentFuncTypeEncoder<'_>
component-model
only.Define a function type in this type section.
Sourcepub fn defined_type(&mut self) -> ComponentDefinedTypeEncoder<'_>
Available on crate feature component-model
only.
pub fn defined_type(&mut self) -> ComponentDefinedTypeEncoder<'_>
component-model
only.Add a component defined type to this type section.
The returned encoder must be used before adding another type.
Trait Implementations§
Source§impl Clone for ComponentTypeSection
Available on crate feature component-model
only.
impl Clone for ComponentTypeSection
Available on crate feature
component-model
only.Source§fn clone(&self) -> ComponentTypeSection
fn clone(&self) -> ComponentTypeSection
Returns a duplicate 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 moreSource§impl ComponentSection for ComponentTypeSection
Available on crate feature component-model
only.
impl ComponentSection for ComponentTypeSection
Available on crate feature
component-model
only.Source§impl Debug for ComponentTypeSection
Available on crate feature component-model
only.
impl Debug for ComponentTypeSection
Available on crate feature
component-model
only.Source§impl Default for ComponentTypeSection
Available on crate feature component-model
only.
impl Default for ComponentTypeSection
Available on crate feature
component-model
only.Source§fn default() -> ComponentTypeSection
fn default() -> ComponentTypeSection
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ComponentTypeSection
impl RefUnwindSafe for ComponentTypeSection
impl Send for ComponentTypeSection
impl Sync for ComponentTypeSection
impl Unpin for ComponentTypeSection
impl UnwindSafe for ComponentTypeSection
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more