Struct wasm_encoder::ComponentTypeSection
source · 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(PrimitiveValType::String);
let mut component = Component::new();
component.section(&types);
let bytes = component.finish();
Implementations§
source§impl ComponentTypeSection
impl ComponentTypeSection
sourcepub fn ty(&mut self) -> ComponentTypeEncoder<'_>
pub fn ty(&mut self) -> ComponentTypeEncoder<'_>
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
pub fn component(&mut self, ty: &ComponentType) -> &mut Self
Define a component type in this type section.
sourcepub fn instance(&mut self, ty: &InstanceType) -> &mut Self
pub fn instance(&mut self, ty: &InstanceType) -> &mut Self
Define an instance type in this type section.
sourcepub fn function(&mut self) -> ComponentFuncTypeEncoder<'_>
pub fn function(&mut self) -> ComponentFuncTypeEncoder<'_>
Define a function type in this type section.
sourcepub fn defined_type(&mut self) -> ComponentDefinedTypeEncoder<'_>
pub fn defined_type(&mut self) -> ComponentDefinedTypeEncoder<'_>
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
impl Clone for ComponentTypeSection
source§fn clone(&self) -> ComponentTypeSection
fn clone(&self) -> ComponentTypeSection
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 moresource§impl Debug for ComponentTypeSection
impl Debug for ComponentTypeSection
source§impl Default for ComponentTypeSection
impl Default for ComponentTypeSection
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)