pub struct ComponentImportSection { /* private fields */ }
Available on crate feature
component-model
only.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§
Source§impl ComponentImportSection
impl ComponentImportSection
Sourcepub fn import(&mut self, name: &str, ty: ComponentTypeRef) -> &mut Self
pub fn import(&mut self, name: &str, ty: ComponentTypeRef) -> &mut Self
Define an import in the component import section.
Trait Implementations§
Source§impl Clone for ComponentImportSection
impl Clone for ComponentImportSection
Source§fn clone(&self) -> ComponentImportSection
fn clone(&self) -> ComponentImportSection
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 ComponentImportSection
impl Debug for ComponentImportSection
Source§impl Default for ComponentImportSection
impl Default for ComponentImportSection
Source§fn default() -> ComponentImportSection
fn default() -> ComponentImportSection
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ComponentImportSection
impl RefUnwindSafe for ComponentImportSection
impl Send for ComponentImportSection
impl Sync for ComponentImportSection
impl Unpin for ComponentImportSection
impl UnwindSafe for ComponentImportSection
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
)