Struct wasm_encoder::component::TypeSection
source · [−]pub struct TypeSection { /* private fields */ }
Expand description
An encoder for the component type section.
Example
use wasm_encoder::component::{Component, TypeSection, InterfaceType};
let mut types = TypeSection::new();
types.function(&[], &[]);
// list<u8>
let mut encoder = types.compound();
encoder.list(InterfaceType::U8);
// record { foo: list<u8> }
let mut encoder = types.compound();
encoder.record(&[("foo", InterfaceType::Compound(1))]);
let mut component = Component::new();
component.section(&types);
let bytes = component.finish();
Implementations
sourceimpl TypeSection
impl TypeSection
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 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 function(&mut self, params: &[ValType], results: &[ValType]) -> &mut Self
pub fn function(&mut self, params: &[ValType], results: &[ValType]) -> &mut Self
Define a function type in this type section.
sourcepub fn adapter_function(
&mut self,
params: &[(&str, InterfaceType)],
results: &[(Option<&str>, InterfaceType)]
) -> &mut Self
pub fn adapter_function(
&mut self,
params: &[(&str, InterfaceType)],
results: &[(Option<&str>, InterfaceType)]
) -> &mut Self
Define an adapter function type.
Panics
This function panics if the given results are not all unnamed (i.e. None
) or
all named (i.e. Some
).
sourcepub fn compound(&mut self) -> CompoundTypeEncoder<'_>
pub fn compound(&mut self) -> CompoundTypeEncoder<'_>
Define a compound type.
Trait Implementations
sourceimpl Clone for TypeSection
impl Clone for TypeSection
sourcefn clone(&self) -> TypeSection
fn clone(&self) -> TypeSection
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 ComponentSection for TypeSection
impl ComponentSection for TypeSection
sourceimpl Debug for TypeSection
impl Debug for TypeSection
sourceimpl Default for TypeSection
impl Default for TypeSection
sourcefn default() -> TypeSection
fn default() -> TypeSection
Returns the “default value” for a type. Read more
Auto Trait Implementations
impl RefUnwindSafe for TypeSection
impl Send for TypeSection
impl Sync for TypeSection
impl Unpin for TypeSection
impl UnwindSafe for TypeSection
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub 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.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more