wasmtime_environ

Struct ModuleTypesBuilder

source
pub struct ModuleTypesBuilder { /* private fields */ }
Expand description

A builder for ModuleTypes.

Implementations§

source§

impl ModuleTypesBuilder

source

pub fn new(validator: &Validator) -> Self

Construct a new ModuleTypesBuilder using the given validator.

source

pub fn reserve_wasm_signatures(&mut self, amt: usize)

Reserves space for amt more type signatures.

source

pub fn validator_id(&self) -> ValidatorId

Get the id of the validator that this builder is configured for.

source

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.

source

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.

source

pub fn finish(self) -> ModuleTypes

Returns the result ModuleTypes of this builder.

source

pub fn rec_group_elements( &self, rec_group: ModuleInternedRecGroupIndex, ) -> impl ExactSizeIterator<Item = ModuleInternedTypeIndex>

Get the elements within an already-defined rec group.

source

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.

source

pub fn trampoline_types( &self, ) -> impl Iterator<Item = (ModuleInternedTypeIndex, ModuleInternedTypeIndex)> + '_

Get an iterator over all function types and their associated trampoline type.

source

pub fn trampoline_type( &self, ty: ModuleInternedTypeIndex, ) -> ModuleInternedTypeIndex

Get the associated trampoline type for the given function type.

source

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.

source

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.

Trait Implementations§

source§

impl<T> Index<T> for ModuleTypesBuilder
where ModuleTypes: Index<T>,

source§

type Output = <ModuleTypes as Index<T>>::Output

The returned type after indexing.
source§

fn index(&self, sig: T) -> &Self::Output

Performs the indexing (container[index]) operation. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.