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.