pub struct InstanceSection { /* private fields */ }Expand description
An encoder for the core instance section of WebAssembly components.
§Example
use wasm_encoder::{Component, InstanceSection, ExportKind, ModuleArg};
let mut instances = InstanceSection::new();
instances.export_items([("foo", ExportKind::Func, 0)]);
instances.instantiate(1, [("foo", ModuleArg::Instance(0))]);
let mut component = Component::new();
component.section(&instances);
let bytes = component.finish();Implementations§
Source§impl InstanceSection
impl InstanceSection
Sourcepub fn new() -> Self
Available on crate feature component-model only.
pub fn new() -> Self
component-model only.Create a new core instance section encoder.
Sourcepub fn len(&self) -> u32
Available on crate feature component-model only.
pub fn len(&self) -> u32
component-model only.The number of instances in the section.
Sourcepub fn is_empty(&self) -> bool
Available on crate feature component-model only.
pub fn is_empty(&self) -> bool
component-model only.Determines if the section is empty.
Sourcepub fn instantiate<A, S>(&mut self, module_index: u32, args: A) -> &mut Self
Available on crate feature component-model only.
pub fn instantiate<A, S>(&mut self, module_index: u32, args: A) -> &mut Self
component-model only.Define an instance by instantiating a core module.
Sourcepub fn export_items<E, S>(&mut self, exports: E) -> &mut Self
Available on crate feature component-model only.
pub fn export_items<E, S>(&mut self, exports: E) -> &mut Self
component-model only.Define an instance by exporting core WebAssembly items.
Trait Implementations§
Source§impl Clone for InstanceSection
Available on crate feature component-model only.
impl Clone for InstanceSection
Available on crate feature
component-model only.Source§fn clone(&self) -> InstanceSection
fn clone(&self) -> InstanceSection
Returns a duplicate 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 ComponentSection for InstanceSection
Available on crate feature component-model only.
impl ComponentSection for InstanceSection
Available on crate feature
component-model only.Source§impl Debug for InstanceSection
Available on crate feature component-model only.
impl Debug for InstanceSection
Available on crate feature
component-model only.Source§impl Default for InstanceSection
Available on crate feature component-model only.
impl Default for InstanceSection
Available on crate feature
component-model only.Source§fn default() -> InstanceSection
fn default() -> InstanceSection
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for InstanceSection
impl RefUnwindSafe for InstanceSection
impl Send for InstanceSection
impl Sync for InstanceSection
impl Unpin for InstanceSection
impl UnwindSafe for InstanceSection
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