TypesRef

Struct TypesRef 

pub struct TypesRef<'a> { /* private fields */ }
Expand description

Represents the types known to a crate::Validator during validation.

Retrieved via the crate::Validator::types method.

Implementations§

§

impl<'a> TypesRef<'a>

pub fn core_type_at_in_component(&self, index: u32) -> ComponentCoreTypeId

Gets a core WebAssembly type id from a type index.

Note that this is not to be confused with TypesRef::component_type_at which gets a component type from its index, nor TypesRef::core_type_count_in_module which does not work for components.

§Panics

This will panic if the index provided is out of bounds.

pub fn core_type_count_in_component(&self) -> u32

Returns the number of core types defined so far within a component.

This should only be used for components. For modules see TypesRef::core_type_count_in_module.

pub fn component_any_type_at(&self, index: u32) -> ComponentAnyTypeId

Gets a type id from a type index.

§Panics

Panics if index is not a valid type index or if this type information represents a core module.

pub fn component_type_at(&self, index: u32) -> ComponentTypeId

Gets a component type id from a type index.

§Panics

Panics if index is not a valid component type index or if this type information represents a core module.

pub fn component_defined_type_at(&self, index: u32) -> ComponentDefinedTypeId

Gets a type id from a type index.

§Panics

Panics if index is not a valid function index or if this type information represents a core module.

pub fn component_type_count(&self) -> u32

Returns the number of component types defined so far.

pub fn component_function_at(&self, index: u32) -> ComponentFuncTypeId

Gets the type of a component function at the given function index.

§Panics

This will panic if the index provided is out of bounds or if this type information represents a core module.

pub fn component_function_count(&self) -> u32

Returns the number of component functions defined so far.

pub fn module_at(&self, index: u32) -> ComponentCoreModuleTypeId

Gets the type of a module at the given module index.

§Panics

This will panic if the index provided is out of bounds or if this type information represents a core module.

pub fn module_count(&self) -> u32

Returns the number of core wasm modules defined so far.

pub fn core_instance_at(&self, index: u32) -> ComponentCoreInstanceTypeId

Gets the type of a module instance at the given module instance index.

§Panics

This will panic if the index provided is out of bounds or if this type information represents a core module.

pub fn core_instance_count(&self) -> u32

Returns the number of core wasm instances defined so far.

pub fn component_at(&self, index: u32) -> ComponentTypeId

Gets the type of a component at the given component index.

§Panics

This will panic if the index provided is out of bounds or if this type information represents a core module.

pub fn component_count(&self) -> u32

Returns the number of components defined so far.

pub fn component_instance_at(&self, index: u32) -> ComponentInstanceTypeId

Gets the type of an component instance at the given component instance index.

§Panics

This will panic if the index provided is out of bounds or if this type information represents a core module.

pub fn component_instance_count(&self) -> u32

Returns the number of component instances defined so far.

pub fn value_at(&self, index: u32) -> ComponentValType

Gets the type of a value at the given value index.

§Panics

This will panic if the index provided is out of bounds or if this type information represents a core module.

pub fn value_count(&self) -> u32

Returns the number of component values defined so far.

pub fn component_entity_type_of_import( &self, name: &str, ) -> Option<ComponentEntityType>

Gets the component entity type for the given component import.

pub fn component_entity_type_of_export( &self, name: &str, ) -> Option<ComponentEntityType>

Gets the component entity type for the given component export.

pub fn peel_alias<T>(&self, ty: T) -> Option<T>
where T: Aliasable,

Attempts to lookup the type id that ty is an alias of.

Returns None if ty wasn’t listed as aliasing a prior type.

§

impl<'a> TypesRef<'a>

pub fn id(&self) -> ValidatorId

Get the id of the validator that these types are associated with.

pub fn get<T>(&self, id: T) -> Option<&'a <T as TypeIdentifier>::Data>
where T: TypeIdentifier,

Gets a type based on its type id.

Returns None if the type id is unknown.

pub fn rec_group_id_of(&self, id: CoreTypeId) -> RecGroupId

Get the id of the rec group that the given type id was defined within.

pub fn rec_group_elements(&self, id: RecGroupId) -> impl ExactSizeIterator

Get the types within a rec group.

pub fn supertype_of(&self, id: CoreTypeId) -> Option<CoreTypeId>

Get the super type of the given type id, if any.

pub fn core_type_at_in_module(&self, index: u32) -> CoreTypeId

Gets a core WebAssembly type id from a type index.

Note that this is not to be confused with TypesRef::component_type_at which gets a component type from its index, nor TypesRef::core_type_at_in_component which is for learning about core types in components.

§Panics

This will panic if the index provided is out of bounds.

pub fn core_type_count_in_module(&self) -> u32

Returns the number of core types defined so far.

Note that this is only for core modules, for components you should use TypesRef::core_type_count_in_component instead.

pub fn table_at(&self, index: u32) -> TableType

Gets the type of a table at the given table index.

§Panics

This will panic if the index provided is out of bounds.

pub fn table_count(&self) -> u32

Returns the number of tables defined so far.

pub fn memory_at(&self, index: u32) -> MemoryType

Gets the type of a memory at the given memory index.

§Panics

This will panic if the index provided is out of bounds.

pub fn memory_count(&self) -> u32

Returns the number of memories defined so far.

pub fn global_at(&self, index: u32) -> GlobalType

Gets the type of a global at the given global index.

§Panics

This will panic if the index provided is out of bounds.

pub fn global_count(&self) -> u32

Returns the number of globals defined so far.

pub fn tag_at(&self, index: u32) -> CoreTypeId

Gets the type of a tag at the given tag index.

§Panics

This will panic if the index provided is out of bounds.

pub fn tag_count(&self) -> u32

Returns the number of tags defined so far.

pub fn core_function_at(&self, index: u32) -> CoreTypeId

Gets the type of a core function at the given function index.

§Panics

This will panic if the index provided is out of bounds.

pub fn function_count(&self) -> u32

Gets the count of core functions defined so far.

Note that this includes imported functions, defined functions, and for components lowered/aliased functions.

pub fn element_at(&self, index: u32) -> RefType

Gets the type of an element segment at the given element segment index.

§Panics

This will panic if the index provided is out of bounds.

pub fn element_count(&self) -> u32

Returns the number of elements defined so far.

pub fn entity_type_from_import(&self, import: &Import<'_>) -> Option<EntityType>

Gets the entity type for the given import.

pub fn entity_type_from_export(&self, export: &Export<'_>) -> Option<EntityType>

Gets the entity type from the given export.

pub fn core_imports( &self, ) -> Option<impl Iterator<Item = (&'a str, &'a str, EntityType)> + 'a>

Returns an iterator over the core wasm imports found.

Returns None if this type information is for a component.

pub fn core_exports( &self, ) -> Option<impl Iterator<Item = (&'a str, EntityType)> + 'a>

Returns an iterator over the core wasm exports found.

Returns None if this type information is for a component.

Trait Implementations§

§

impl<'a> Clone for TypesRef<'a>

§

fn clone(&self) -> TypesRef<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl<T> Index<T> for TypesRef<'_>
where T: TypeIdentifier,

§

type Output = <T as TypeIdentifier>::Data

The returned type after indexing.
§

fn index(&self, index: T) -> &<TypesRef<'_> as Index<T>>::Output

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

impl<'a> Copy for TypesRef<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for TypesRef<'a>

§

impl<'a> RefUnwindSafe for TypesRef<'a>

§

impl<'a> Send for TypesRef<'a>

§

impl<'a> Sync for TypesRef<'a>

§

impl<'a> Unpin for TypesRef<'a>

§

impl<'a> UnwindSafe for TypesRef<'a>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Pointee for T

Source§

type Pointer = u32

Source§

fn debug( pointer: <T as Pointee>::Pointer, f: &mut Formatter<'_>, ) -> Result<(), Error>

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more