Struct wasm_encoder::component::InstanceSection
source · [−]pub struct InstanceSection { /* private fields */ }
Expand description
An encoder for the component instance section.
Example
use wasm_encoder::component::{Component, InstanceSection, IndexRef};
// This assumes there is a module with index 0, a function with index 0,
// a module with index 2, and a global with index 0.
let mut instances = InstanceSection::new();
instances.instantiate(0, [
("x", IndexRef::Function(0)),
("", IndexRef::Module(2)),
("foo", IndexRef::Global(0)),
]);
let mut component = Component::new();
component.section(&instances);
let bytes = component.finish();
Implementations
sourceimpl InstanceSection
impl InstanceSection
sourcepub fn instantiate<'a, I>(&mut self, module: u32, args: I) -> &mut Self where
I: IntoIterator<Item = (&'a str, IndexRef)>,
I::IntoIter: ExactSizeIterator,
pub fn instantiate<'a, I>(&mut self, module: u32, args: I) -> &mut Self where
I: IntoIterator<Item = (&'a str, IndexRef)>,
I::IntoIter: ExactSizeIterator,
Define an instantiation of the given module with the given arguments to the instantiation.
sourcepub fn exports<'a, E>(&mut self, exports: E) -> &mut Self where
E: IntoIterator<Item = (&'a str, IndexRef)>,
E::IntoIter: ExactSizeIterator,
pub fn exports<'a, E>(&mut self, exports: E) -> &mut Self where
E: IntoIterator<Item = (&'a str, IndexRef)>,
E::IntoIter: ExactSizeIterator,
Define an instance by exporting the given exports.
Trait Implementations
sourceimpl Clone for InstanceSection
impl Clone for InstanceSection
sourcefn clone(&self) -> InstanceSection
fn clone(&self) -> InstanceSection
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 more
sourceimpl ComponentSection for InstanceSection
impl ComponentSection for InstanceSection
sourceimpl Debug for InstanceSection
impl Debug for InstanceSection
sourceimpl Default for InstanceSection
impl Default for InstanceSection
sourcefn default() -> InstanceSection
fn default() -> InstanceSection
Returns the “default value” for a type. Read more
Auto Trait Implementations
impl RefUnwindSafe for InstanceSection
impl Send for InstanceSection
impl Sync for InstanceSection
impl Unpin for InstanceSection
impl UnwindSafe for InstanceSection
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more