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§
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