pub struct ComponentInstanceSection { /* private fields */ }
Expand description
An encoder for the instance section of WebAssembly components.
§Example
use wasm_encoder::{Component, ComponentInstanceSection, ComponentExportKind};
let mut instances = ComponentInstanceSection::new();
instances.export_items([("foo", ComponentExportKind::Func, 0)]);
instances.instantiate(1, [("foo", ComponentExportKind::Instance, 0)]);
let mut component = Component::new();
component.section(&instances);
let bytes = component.finish();
Implementations§
Source§impl ComponentInstanceSection
impl ComponentInstanceSection
Sourcepub fn new() -> Self
Available on crate feature component-model
only.
pub fn new() -> Self
component-model
only.Create a new 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, component_index: u32, args: A) -> &mut Selfwhere
A: IntoIterator<Item = (S, ComponentExportKind, u32)>,
A::IntoIter: ExactSizeIterator,
S: AsRef<str>,
Available on crate feature component-model
only.
pub fn instantiate<A, S>(&mut self, component_index: u32, args: A) -> &mut Selfwhere
A: IntoIterator<Item = (S, ComponentExportKind, u32)>,
A::IntoIter: ExactSizeIterator,
S: AsRef<str>,
component-model
only.Define an instance by instantiating a component.
Sourcepub fn export_items<'a, E>(&mut self, exports: E) -> &mut Self
Available on crate feature component-model
only.
pub fn export_items<'a, E>(&mut self, exports: E) -> &mut Self
component-model
only.Define an instance by exporting items.
Trait Implementations§
Source§impl Clone for ComponentInstanceSection
Available on crate feature component-model
only.
impl Clone for ComponentInstanceSection
Available on crate feature
component-model
only.Source§fn clone(&self) -> ComponentInstanceSection
fn clone(&self) -> ComponentInstanceSection
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 ComponentInstanceSection
Available on crate feature component-model
only.
impl ComponentSection for ComponentInstanceSection
Available on crate feature
component-model
only.Source§impl Debug for ComponentInstanceSection
Available on crate feature component-model
only.
impl Debug for ComponentInstanceSection
Available on crate feature
component-model
only.Source§impl Default for ComponentInstanceSection
Available on crate feature component-model
only.
impl Default for ComponentInstanceSection
Available on crate feature
component-model
only.Source§fn default() -> ComponentInstanceSection
fn default() -> ComponentInstanceSection
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ComponentInstanceSection
impl RefUnwindSafe for ComponentInstanceSection
impl Send for ComponentInstanceSection
impl Sync for ComponentInstanceSection
impl Unpin for ComponentInstanceSection
impl UnwindSafe for ComponentInstanceSection
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