pub struct ModuleTypesBuilder { /* private fields */ }
Expand description
A builder for ModuleTypes
.
Implementations§
source§impl ModuleTypesBuilder
impl ModuleTypesBuilder
sourcepub fn new(validator: &Validator) -> Self
pub fn new(validator: &Validator) -> Self
Construct a new ModuleTypesBuilder
using the given validator.
sourcepub fn reserve_wasm_signatures(&mut self, amt: usize)
pub fn reserve_wasm_signatures(&mut self, amt: usize)
Reserves space for amt
more type signatures.
sourcepub fn validator_id(&self) -> ValidatorId
pub fn validator_id(&self) -> ValidatorId
Get the id of the validator that this builder is configured for.
sourcepub fn intern_rec_group(
&mut self,
validator_types: TypesRef<'_>,
rec_group_id: RecGroupId,
) -> WasmResult<ModuleInternedRecGroupIndex>
pub fn intern_rec_group( &mut self, validator_types: TypesRef<'_>, rec_group_id: RecGroupId, ) -> WasmResult<ModuleInternedRecGroupIndex>
Intern a recursion group and all of its types into this builder.
If the recursion group has already been interned, then it is reused.
Panics if given types from a different validator than the one that this builder is associated with.
sourcepub fn intern_type(
&mut self,
validator_types: TypesRef<'_>,
id: CoreTypeId,
) -> WasmResult<ModuleInternedTypeIndex>
pub fn intern_type( &mut self, validator_types: TypesRef<'_>, id: CoreTypeId, ) -> WasmResult<ModuleInternedTypeIndex>
Intern a type into this builder and get its Wasmtime index.
This will intern not only the single given type, but the type’s entire rec group. This helper method is provided as a convenience so that callers don’t have to get the type’s rec group, intern the rec group, and then look up the Wasmtime index for the original type themselves.
sourcepub fn finish(self) -> ModuleTypes
pub fn finish(self) -> ModuleTypes
Returns the result ModuleTypes
of this builder.
sourcepub fn rec_group_elements(
&self,
rec_group: ModuleInternedRecGroupIndex,
) -> impl ExactSizeIterator<Item = ModuleInternedTypeIndex>
pub fn rec_group_elements( &self, rec_group: ModuleInternedRecGroupIndex, ) -> impl ExactSizeIterator<Item = ModuleInternedTypeIndex>
Get the elements within an already-defined rec group.
sourcepub fn wasm_types(
&self,
) -> impl Iterator<Item = (ModuleInternedTypeIndex, &WasmSubType)>
pub fn wasm_types( &self, ) -> impl Iterator<Item = (ModuleInternedTypeIndex, &WasmSubType)>
Returns an iterator over all the unique wasm types defined thus far within this builder.
sourcepub fn trampoline_types(
&self,
) -> impl Iterator<Item = (ModuleInternedTypeIndex, ModuleInternedTypeIndex)> + '_
pub fn trampoline_types( &self, ) -> impl Iterator<Item = (ModuleInternedTypeIndex, ModuleInternedTypeIndex)> + '_
Get an iterator over all function types and their associated trampoline type.
sourcepub fn trampoline_type(
&self,
ty: ModuleInternedTypeIndex,
) -> ModuleInternedTypeIndex
pub fn trampoline_type( &self, ty: ModuleInternedTypeIndex, ) -> ModuleInternedTypeIndex
Get the associated trampoline type for the given function type.
sourcepub fn unwrap_struct(
&self,
ty: ModuleInternedTypeIndex,
) -> WasmResult<&WasmStructType>
pub fn unwrap_struct( &self, ty: ModuleInternedTypeIndex, ) -> WasmResult<&WasmStructType>
Get and unwrap a WasmStructType
for the given struct index.
§Panics
Panics if the unwrapped type is not a struct.
§Errors
For now, fails with an unsupported error if the type is shared.
sourcepub fn unwrap_array(
&self,
interned_ty: ModuleInternedTypeIndex,
) -> WasmResult<&WasmArrayType>
pub fn unwrap_array( &self, interned_ty: ModuleInternedTypeIndex, ) -> WasmResult<&WasmArrayType>
Get and unwrap a WasmArrayType
for the given array index.
§Panics
Panics if the unwrapped type is not an array.
§Errors
For now, fails with an unsupported error if the type is shared.