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, PrimitiveInterfaceType};
let mut types = ComponentTypeSection::new();
types.function(
[
(Some("a"), PrimitiveInterfaceType::String),
(Some("b"), PrimitiveInterfaceType::String)
],
PrimitiveInterfaceType::String
);
let mut component = Component::new();
component.section(&types);
let bytes = component.finish();Implementations
sourceimpl ComponentTypeSection
impl ComponentTypeSection
sourcepub fn ty(&mut self) -> TypeEncoder<'_>
pub fn ty(&mut self) -> TypeEncoder<'_>
Encode a type into this section.
The returned encoder must be finished before adding another type.
sourcepub fn module(&mut self, ty: &ModuleType) -> &mut Self
pub fn module(&mut self, ty: &ModuleType) -> &mut Self
Define a module type in this type section.
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<'a, P, T>(
&mut self,
params: P,
result: impl Into<InterfaceTypeRef>
) -> &mut Self where
P: IntoIterator<Item = (Option<&'a str>, T)>,
P::IntoIter: ExactSizeIterator,
T: Into<InterfaceTypeRef>,
pub fn function<'a, P, T>(
&mut self,
params: P,
result: impl Into<InterfaceTypeRef>
) -> &mut Self where
P: IntoIterator<Item = (Option<&'a str>, T)>,
P::IntoIter: ExactSizeIterator,
T: Into<InterfaceTypeRef>,
Define a function type in this type section.
sourcepub fn value(&mut self, ty: impl Into<InterfaceTypeRef>) -> &mut Self
pub fn value(&mut self, ty: impl Into<InterfaceTypeRef>) -> &mut Self
Define a value type in this type section.
sourcepub fn interface_type(&mut self) -> InterfaceTypeEncoder<'_>
pub fn interface_type(&mut self) -> InterfaceTypeEncoder<'_>
Define an interface type in this type section.
The returned encoder must be finished before adding another type.
Trait Implementations
sourceimpl Clone for ComponentTypeSection
impl Clone for ComponentTypeSection
sourcefn clone(&self) -> ComponentTypeSection
fn clone(&self) -> ComponentTypeSection
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
sourceimpl Debug for ComponentTypeSection
impl Debug for ComponentTypeSection
sourceimpl Default for ComponentTypeSection
impl Default for ComponentTypeSection
sourcefn default() -> ComponentTypeSection
fn default() -> ComponentTypeSection
Returns the “default value” for a type. Read more
Auto Trait Implementations
impl RefUnwindSafe for ComponentTypeSection
impl Send for ComponentTypeSection
impl Sync for ComponentTypeSection
impl Unpin for ComponentTypeSection
impl UnwindSafe for ComponentTypeSection
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more