Struct wasm_encoder::ComponentImportSection
source · pub struct ComponentImportSection { /* private fields */ }
Expand description
An encoder for the import section of WebAssembly components.
Example
use wasm_encoder::{Component, ComponentTypeSection, PrimitiveValType, ComponentImportSection, ComponentTypeRef};
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);
// This imports a function named `f` with the type defined above
let mut imports = ComponentImportSection::new();
imports.import("f", "", ComponentTypeRef::Func(0));
let mut component = Component::new();
component.section(&types);
component.section(&imports);
let bytes = component.finish();
Implementations
Trait Implementations
sourceimpl Clone for ComponentImportSection
impl Clone for ComponentImportSection
sourcefn clone(&self) -> ComponentImportSection
fn clone(&self) -> ComponentImportSection
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 moresourceimpl Debug for ComponentImportSection
impl Debug for ComponentImportSection
sourceimpl Default for ComponentImportSection
impl Default for ComponentImportSection
sourcefn default() -> ComponentImportSection
fn default() -> ComponentImportSection
Returns the “default value” for a type. Read more
Auto Trait Implementations
impl RefUnwindSafe for ComponentImportSection
impl Send for ComponentImportSection
impl Sync for ComponentImportSection
impl Unpin for ComponentImportSection
impl UnwindSafe for ComponentImportSection
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
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