pub struct ComponentBuilder { /* private fields */ }Expand description
Convenience type to build a component incrementally and automatically keep track of index spaces.
This type is intended to be a wrapper around the Component encoding type
which is useful for building it up incrementally over time. This type will
automatically collect definitions into sections and reports the index of all
items added by keeping track of indices internally.
Implementations§
Source§impl ComponentBuilder
impl ComponentBuilder
Sourcepub fn core_module_count(&self) -> u32
Available on crate feature component-model only.
pub fn core_module_count(&self) -> u32
component-model only.Returns the current number of core modules.
Sourcepub fn core_func_count(&self) -> u32
Available on crate feature component-model only.
pub fn core_func_count(&self) -> u32
component-model only.Returns the current number of core funcs.
Sourcepub fn core_type_count(&self) -> u32
Available on crate feature component-model only.
pub fn core_type_count(&self) -> u32
component-model only.Returns the current number of core types.
Sourcepub fn core_memory_count(&self) -> u32
Available on crate feature component-model only.
pub fn core_memory_count(&self) -> u32
component-model only.Returns the current number of core memories.
Sourcepub fn core_table_count(&self) -> u32
Available on crate feature component-model only.
pub fn core_table_count(&self) -> u32
component-model only.Returns the current number of core tables.
Sourcepub fn core_instance_count(&self) -> u32
Available on crate feature component-model only.
pub fn core_instance_count(&self) -> u32
component-model only.Returns the current number of core instances.
Sourcepub fn core_tag_count(&self) -> u32
Available on crate feature component-model only.
pub fn core_tag_count(&self) -> u32
component-model only.Returns the current number of core tags.
Sourcepub fn core_global_count(&self) -> u32
Available on crate feature component-model only.
pub fn core_global_count(&self) -> u32
component-model only.Returns the current number of core globals.
Sourcepub fn func_count(&self) -> u32
Available on crate feature component-model only.
pub fn func_count(&self) -> u32
component-model only.Returns the current number of component funcs.
Sourcepub fn instance_count(&self) -> u32
Available on crate feature component-model only.
pub fn instance_count(&self) -> u32
component-model only.Returns the current number of component instances.
Sourcepub fn value_count(&self) -> u32
Available on crate feature component-model only.
pub fn value_count(&self) -> u32
component-model only.Returns the current number of component values.
Sourcepub fn component_count(&self) -> u32
Available on crate feature component-model only.
pub fn component_count(&self) -> u32
component-model only.Returns the current number of components.
Sourcepub fn type_count(&self) -> u32
Available on crate feature component-model only.
pub fn type_count(&self) -> u32
component-model only.Returns the current number of component types.
Sourcepub fn append_names(&mut self)
Available on crate feature component-model only.
pub fn append_names(&mut self)
component-model only.Add all debug names registered to the component.
Sourcepub fn finish(self) -> Vec<u8> ⓘ
Available on crate feature component-model only.
pub fn finish(self) -> Vec<u8> ⓘ
component-model only.Completes this component and returns the binary encoding of the entire component.
Sourcepub fn core_module(&mut self, debug_name: Option<&str>, module: &Module) -> u32
Available on crate feature component-model only.
pub fn core_module(&mut self, debug_name: Option<&str>, module: &Module) -> u32
component-model only.Encodes a core wasm Module into this component, returning its index.
Sourcepub fn core_module_raw(
&mut self,
debug_name: Option<&str>,
module: &[u8],
) -> u32
Available on crate feature component-model only.
pub fn core_module_raw( &mut self, debug_name: Option<&str>, module: &[u8], ) -> u32
component-model only.Encodes a core wasm module into this component, returning its index.
Sourcepub fn core_instantiate<'a, A>(
&mut self,
debug_name: Option<&str>,
module_index: u32,
args: A,
) -> u32
Available on crate feature component-model only.
pub fn core_instantiate<'a, A>( &mut self, debug_name: Option<&str>, module_index: u32, args: A, ) -> u32
component-model only.Instantiates a core wasm module at module_index with the args
provided.
Returns the index of the core wasm instance created.
Sourcepub fn core_instantiate_exports<'a, E>(
&mut self,
debug_name: Option<&str>,
exports: E,
) -> u32
Available on crate feature component-model only.
pub fn core_instantiate_exports<'a, E>( &mut self, debug_name: Option<&str>, exports: E, ) -> u32
component-model only.Creates a new core wasm instance from the exports provided.
Returns the index of the core wasm instance created.
Sourcepub fn core_alias_export(
&mut self,
debug_name: Option<&str>,
instance: u32,
name: &str,
kind: ExportKind,
) -> u32
Available on crate feature component-model only.
pub fn core_alias_export( &mut self, debug_name: Option<&str>, instance: u32, name: &str, kind: ExportKind, ) -> u32
component-model only.Creates a new aliased item where the core instance specified has its
export name aliased out with the kind specified.
Returns the index of the item created.
Sourcepub fn alias(&mut self, debug_name: Option<&str>, alias: Alias<'_>) -> u32
Available on crate feature component-model only.
pub fn alias(&mut self, debug_name: Option<&str>, alias: Alias<'_>) -> u32
component-model only.Adds a new alias to this component
Sourcepub fn alias_export(
&mut self,
instance: u32,
name: &str,
kind: ComponentExportKind,
) -> u32
Available on crate feature component-model only.
pub fn alias_export( &mut self, instance: u32, name: &str, kind: ComponentExportKind, ) -> u32
component-model only.Creates an alias to a previous component instance’s exported item.
The instance provided is the instance to access and the name is the
item to access.
Returns the index of the new item defined.
Sourcepub fn lower_func<O>(
&mut self,
debug_name: Option<&str>,
func_index: u32,
options: O,
) -> u32
Available on crate feature component-model only.
pub fn lower_func<O>( &mut self, debug_name: Option<&str>, func_index: u32, options: O, ) -> u32
component-model only.Lowers the func_index component function into a core wasm function
using the options provided.
Returns the index of the core wasm function created.
Sourcepub fn lift_func<O>(
&mut self,
debug_name: Option<&str>,
core_func_index: u32,
type_index: u32,
options: O,
) -> u32
Available on crate feature component-model only.
pub fn lift_func<O>( &mut self, debug_name: Option<&str>, core_func_index: u32, type_index: u32, options: O, ) -> u32
component-model only.Lifts the core wasm core_func_index function with the component
function type type_index and options.
Returns the index of the component function created.
Sourcepub fn import(&mut self, name: &str, ty: ComponentTypeRef) -> u32
Available on crate feature component-model only.
pub fn import(&mut self, name: &str, ty: ComponentTypeRef) -> u32
component-model only.Imports a new item into this component with the name and ty specified.
Sourcepub fn export(
&mut self,
name: &str,
kind: ComponentExportKind,
idx: u32,
ty: Option<ComponentTypeRef>,
) -> u32
Available on crate feature component-model only.
pub fn export( &mut self, name: &str, kind: ComponentExportKind, idx: u32, ty: Option<ComponentTypeRef>, ) -> u32
component-model only.Exports a new item from this component with the name and kind
specified.
The idx is the item to export and the ty is an optional type to
ascribe to the export.
Sourcepub fn core_type(
&mut self,
debug_name: Option<&str>,
) -> (u32, ComponentCoreTypeEncoder<'_>)
Available on crate feature component-model only.
pub fn core_type( &mut self, debug_name: Option<&str>, ) -> (u32, ComponentCoreTypeEncoder<'_>)
component-model only.Creates a new encoder for the next core type in this component.
Sourcepub fn ty(
&mut self,
debug_name: Option<&str>,
) -> (u32, ComponentTypeEncoder<'_>)
Available on crate feature component-model only.
pub fn ty( &mut self, debug_name: Option<&str>, ) -> (u32, ComponentTypeEncoder<'_>)
component-model only.Creates a new encoder for the next type in this component.
Sourcepub fn type_instance(
&mut self,
debug_name: Option<&str>,
ty: &InstanceType,
) -> u32
Available on crate feature component-model only.
pub fn type_instance( &mut self, debug_name: Option<&str>, ty: &InstanceType, ) -> u32
component-model only.Creates a new instance type within this component.
Sourcepub fn type_component(
&mut self,
debug_name: Option<&str>,
ty: &ComponentType,
) -> u32
Available on crate feature component-model only.
pub fn type_component( &mut self, debug_name: Option<&str>, ty: &ComponentType, ) -> u32
component-model only.Creates a new component type within this component.
Sourcepub fn type_defined(
&mut self,
debug_name: Option<&str>,
) -> (u32, ComponentDefinedTypeEncoder<'_>)
Available on crate feature component-model only.
pub fn type_defined( &mut self, debug_name: Option<&str>, ) -> (u32, ComponentDefinedTypeEncoder<'_>)
component-model only.Creates a new defined component type within this component.
Sourcepub fn type_function(
&mut self,
debug_name: Option<&str>,
) -> (u32, ComponentFuncTypeEncoder<'_>)
Available on crate feature component-model only.
pub fn type_function( &mut self, debug_name: Option<&str>, ) -> (u32, ComponentFuncTypeEncoder<'_>)
component-model only.Creates a new component function type within this component.
Sourcepub fn type_resource(
&mut self,
debug_name: Option<&str>,
rep: ValType,
dtor: Option<u32>,
) -> u32
Available on crate feature component-model only.
pub fn type_resource( &mut self, debug_name: Option<&str>, rep: ValType, dtor: Option<u32>, ) -> u32
component-model only.Declares a new resource type within this component.
Sourcepub fn component(
&mut self,
debug_name: Option<&str>,
builder: ComponentBuilder,
) -> u32
Available on crate feature component-model only.
pub fn component( &mut self, debug_name: Option<&str>, builder: ComponentBuilder, ) -> u32
component-model only.Defines a new subcomponent of this component.
Sourcepub fn component_raw(&mut self, debug_name: Option<&str>, data: &[u8]) -> u32
Available on crate feature component-model only.
pub fn component_raw(&mut self, debug_name: Option<&str>, data: &[u8]) -> u32
component-model only.Defines a new subcomponent of this component.
Sourcepub fn instantiate<A, S>(
&mut self,
debug_name: Option<&str>,
component_index: u32,
args: A,
) -> u32where
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,
debug_name: Option<&str>,
component_index: u32,
args: A,
) -> u32where
A: IntoIterator<Item = (S, ComponentExportKind, u32)>,
A::IntoIter: ExactSizeIterator,
S: AsRef<str>,
component-model only.Instantiates the component_index specified with the args specified.
Sourcepub fn resource_drop(&mut self, ty: u32) -> u32
Available on crate feature component-model only.
pub fn resource_drop(&mut self, ty: u32) -> u32
component-model only.Declares a new resource.drop intrinsic.
Sourcepub fn resource_drop_async(&mut self, ty: u32) -> u32
Available on crate feature component-model only.
pub fn resource_drop_async(&mut self, ty: u32) -> u32
component-model only.Declares a new resource.drop intrinsic.
Sourcepub fn resource_new(&mut self, ty: u32) -> u32
Available on crate feature component-model only.
pub fn resource_new(&mut self, ty: u32) -> u32
component-model only.Declares a new resource.new intrinsic.
Sourcepub fn resource_rep(&mut self, ty: u32) -> u32
Available on crate feature component-model only.
pub fn resource_rep(&mut self, ty: u32) -> u32
component-model only.Declares a new resource.rep intrinsic.
Sourcepub fn thread_spawn_ref(&mut self, ty: u32) -> u32
Available on crate feature component-model only.
pub fn thread_spawn_ref(&mut self, ty: u32) -> u32
component-model only.Declares a new thread.spawn_ref intrinsic.
Sourcepub fn thread_available_parallelism(&mut self) -> u32
Available on crate feature component-model only.
pub fn thread_available_parallelism(&mut self) -> u32
component-model only.Declares a new thread.available_parallelism intrinsic.
Sourcepub fn backpressure_set(&mut self) -> u32
Available on crate feature component-model only.
pub fn backpressure_set(&mut self) -> u32
component-model only.Declares a new backpressure.set intrinsic.
Sourcepub fn backpressure_inc(&mut self) -> u32
Available on crate feature component-model only.
pub fn backpressure_inc(&mut self) -> u32
component-model only.Declares a new backpressure.inc intrinsic.
Sourcepub fn backpressure_dec(&mut self) -> u32
Available on crate feature component-model only.
pub fn backpressure_dec(&mut self) -> u32
component-model only.Declares a new backpressure.dec intrinsic.
Sourcepub fn task_return<O>(
&mut self,
ty: Option<ComponentValType>,
options: O,
) -> u32
Available on crate feature component-model only.
pub fn task_return<O>( &mut self, ty: Option<ComponentValType>, options: O, ) -> u32
component-model only.Declares a new task.return intrinsic.
Sourcepub fn task_cancel(&mut self) -> u32
Available on crate feature component-model only.
pub fn task_cancel(&mut self) -> u32
component-model only.Declares a new task.cancel intrinsic.
Sourcepub fn context_get(&mut self, i: u32) -> u32
Available on crate feature component-model only.
pub fn context_get(&mut self, i: u32) -> u32
component-model only.Declares a new context.get intrinsic.
Sourcepub fn context_set(&mut self, i: u32) -> u32
Available on crate feature component-model only.
pub fn context_set(&mut self, i: u32) -> u32
component-model only.Declares a new context.set intrinsic.
Sourcepub fn thread_yield(&mut self, cancellable: bool) -> u32
Available on crate feature component-model only.
pub fn thread_yield(&mut self, cancellable: bool) -> u32
component-model only.Declares a new thread.yield intrinsic.
Sourcepub fn subtask_drop(&mut self) -> u32
Available on crate feature component-model only.
pub fn subtask_drop(&mut self) -> u32
component-model only.Declares a new subtask.drop intrinsic.
Sourcepub fn subtask_cancel(&mut self, async_: bool) -> u32
Available on crate feature component-model only.
pub fn subtask_cancel(&mut self, async_: bool) -> u32
component-model only.Declares a new subtask.cancel intrinsic.
Sourcepub fn stream_new(&mut self, ty: u32) -> u32
Available on crate feature component-model only.
pub fn stream_new(&mut self, ty: u32) -> u32
component-model only.Declares a new stream.new intrinsic.
Sourcepub fn stream_read<O>(&mut self, ty: u32, options: O) -> u32
Available on crate feature component-model only.
pub fn stream_read<O>(&mut self, ty: u32, options: O) -> u32
component-model only.Declares a new stream.read intrinsic.
Sourcepub fn stream_write<O>(&mut self, ty: u32, options: O) -> u32
Available on crate feature component-model only.
pub fn stream_write<O>(&mut self, ty: u32, options: O) -> u32
component-model only.Declares a new stream.write intrinsic.
Sourcepub fn stream_cancel_read(&mut self, ty: u32, async_: bool) -> u32
Available on crate feature component-model only.
pub fn stream_cancel_read(&mut self, ty: u32, async_: bool) -> u32
component-model only.Declares a new stream.cancel-read intrinsic.
Sourcepub fn stream_cancel_write(&mut self, ty: u32, async_: bool) -> u32
Available on crate feature component-model only.
pub fn stream_cancel_write(&mut self, ty: u32, async_: bool) -> u32
component-model only.Declares a new stream.cancel-write intrinsic.
Sourcepub fn stream_drop_readable(&mut self, ty: u32) -> u32
Available on crate feature component-model only.
pub fn stream_drop_readable(&mut self, ty: u32) -> u32
component-model only.Declares a new stream.drop-readable intrinsic.
Sourcepub fn stream_drop_writable(&mut self, ty: u32) -> u32
Available on crate feature component-model only.
pub fn stream_drop_writable(&mut self, ty: u32) -> u32
component-model only.Declares a new stream.drop-writable intrinsic.
Sourcepub fn future_new(&mut self, ty: u32) -> u32
Available on crate feature component-model only.
pub fn future_new(&mut self, ty: u32) -> u32
component-model only.Declares a new future.new intrinsic.
Sourcepub fn future_read<O>(&mut self, ty: u32, options: O) -> u32
Available on crate feature component-model only.
pub fn future_read<O>(&mut self, ty: u32, options: O) -> u32
component-model only.Declares a new future.read intrinsic.
Sourcepub fn future_write<O>(&mut self, ty: u32, options: O) -> u32
Available on crate feature component-model only.
pub fn future_write<O>(&mut self, ty: u32, options: O) -> u32
component-model only.Declares a new future.write intrinsic.
Sourcepub fn future_cancel_read(&mut self, ty: u32, async_: bool) -> u32
Available on crate feature component-model only.
pub fn future_cancel_read(&mut self, ty: u32, async_: bool) -> u32
component-model only.Declares a new future.cancel-read intrinsic.
Sourcepub fn future_cancel_write(&mut self, ty: u32, async_: bool) -> u32
Available on crate feature component-model only.
pub fn future_cancel_write(&mut self, ty: u32, async_: bool) -> u32
component-model only.Declares a new future.cancel-write intrinsic.
Sourcepub fn future_drop_readable(&mut self, ty: u32) -> u32
Available on crate feature component-model only.
pub fn future_drop_readable(&mut self, ty: u32) -> u32
component-model only.Declares a new future.drop-readable intrinsic.
Sourcepub fn future_drop_writable(&mut self, ty: u32) -> u32
Available on crate feature component-model only.
pub fn future_drop_writable(&mut self, ty: u32) -> u32
component-model only.Declares a new future.drop-writable intrinsic.
Sourcepub fn error_context_new<O>(&mut self, options: O) -> u32
Available on crate feature component-model only.
pub fn error_context_new<O>(&mut self, options: O) -> u32
component-model only.Declares a new error-context.new intrinsic.
Sourcepub fn error_context_debug_message<O>(&mut self, options: O) -> u32
Available on crate feature component-model only.
pub fn error_context_debug_message<O>(&mut self, options: O) -> u32
component-model only.Declares a new error-context.debug-message intrinsic.
Sourcepub fn error_context_drop(&mut self) -> u32
Available on crate feature component-model only.
pub fn error_context_drop(&mut self) -> u32
component-model only.Declares a new error-context.drop intrinsic.
Sourcepub fn waitable_set_new(&mut self) -> u32
Available on crate feature component-model only.
pub fn waitable_set_new(&mut self) -> u32
component-model only.Declares a new waitable-set.new intrinsic.
Sourcepub fn waitable_set_wait(&mut self, cancellable: bool, memory: u32) -> u32
Available on crate feature component-model only.
pub fn waitable_set_wait(&mut self, cancellable: bool, memory: u32) -> u32
component-model only.Declares a new waitable-set.wait intrinsic.
Sourcepub fn waitable_set_poll(&mut self, cancellable: bool, memory: u32) -> u32
Available on crate feature component-model only.
pub fn waitable_set_poll(&mut self, cancellable: bool, memory: u32) -> u32
component-model only.Declares a new waitable-set.poll intrinsic.
Sourcepub fn waitable_set_drop(&mut self) -> u32
Available on crate feature component-model only.
pub fn waitable_set_drop(&mut self) -> u32
component-model only.Declares a new waitable-set.drop intrinsic.
Sourcepub fn waitable_join(&mut self) -> u32
Available on crate feature component-model only.
pub fn waitable_join(&mut self) -> u32
component-model only.Declares a new waitable.join intrinsic.
Sourcepub fn thread_index(&mut self) -> u32
Available on crate feature component-model only.
pub fn thread_index(&mut self) -> u32
component-model only.Declares a new thread.index intrinsic.
Sourcepub fn thread_new_indirect(&mut self, func_ty_idx: u32, table_index: u32) -> u32
Available on crate feature component-model only.
pub fn thread_new_indirect(&mut self, func_ty_idx: u32, table_index: u32) -> u32
component-model only.Declares a new thread.new_indirect intrinsic.
Sourcepub fn thread_switch_to(&mut self, cancellable: bool) -> u32
Available on crate feature component-model only.
pub fn thread_switch_to(&mut self, cancellable: bool) -> u32
component-model only.Declares a new thread.switch-to intrinsic.
Sourcepub fn thread_suspend(&mut self, cancellable: bool) -> u32
Available on crate feature component-model only.
pub fn thread_suspend(&mut self, cancellable: bool) -> u32
component-model only.Declares a new thread.suspend intrinsic.
Sourcepub fn thread_resume_later(&mut self) -> u32
Available on crate feature component-model only.
pub fn thread_resume_later(&mut self) -> u32
component-model only.Declares a new thread.resume-later intrinsic.
Sourcepub fn thread_yield_to(&mut self, cancellable: bool) -> u32
Available on crate feature component-model only.
pub fn thread_yield_to(&mut self, cancellable: bool) -> u32
component-model only.Declares a new thread.yield-to intrinsic.
Sourcepub fn custom_section(&mut self, section: &CustomSection<'_>)
Available on crate feature component-model only.
pub fn custom_section(&mut self, section: &CustomSection<'_>)
component-model only.Adds a new custom section to this component.
Sourcepub fn raw_custom_section(&mut self, section: &[u8])
Available on crate feature component-model only.
pub fn raw_custom_section(&mut self, section: &[u8])
component-model only.Adds a new custom section to this component.
Trait Implementations§
Source§impl Debug for ComponentBuilder
Available on crate feature component-model only.
impl Debug for ComponentBuilder
component-model only.Source§impl Default for ComponentBuilder
Available on crate feature component-model only.
impl Default for ComponentBuilder
component-model only.