pub struct FuncType { /* private fields */ }Expand description
The type of a WebAssembly function.
WebAssembly functions can have 0 or more parameters and results.
§Subtyping and Equality
FuncType does not implement Eq, because reference types have a subtyping
relationship, and so 99.99% of the time you actually want to check whether
one type matches (i.e. is a subtype of) another type. You can use the
FuncType::matches and Func::matches_ty
methods to perform these types of checks. If, however, you are in that 0.01%
scenario where you need to check precise equality between types, you can use
the FuncType::eq method.
Implementations§
Source§impl FuncType
impl FuncType
Sourcepub fn new(
engine: &Engine,
params: impl IntoIterator<Item = ValType>,
results: impl IntoIterator<Item = ValType>,
) -> FuncType
Available on crate feature runtime only.
pub fn new( engine: &Engine, params: impl IntoIterator<Item = ValType>, results: impl IntoIterator<Item = ValType>, ) -> FuncType
runtime only.Creates a new function type from the given parameters and results.
The function type returned will represent a function which takes
params as arguments and returns results when it is finished.
The resulting function type will be final and without a supertype.
§Panics
Panics if any parameter or value type is not associated with the given engine.
Sourcepub fn with_finality_and_supertype(
engine: &Engine,
finality: Finality,
supertype: Option<&Self>,
params: impl IntoIterator<Item = ValType>,
results: impl IntoIterator<Item = ValType>,
) -> Result<Self>
Available on crate feature runtime only.
pub fn with_finality_and_supertype( engine: &Engine, finality: Finality, supertype: Option<&Self>, params: impl IntoIterator<Item = ValType>, results: impl IntoIterator<Item = ValType>, ) -> Result<Self>
runtime only.Create a new function type with the given finality, supertype, parameter types, and result types.
Returns an error if the supertype is final, or if this function type does not match the supertype.
§Panics
Panics if any parameter or value type is not associated with the given engine.
Sourcepub fn engine(&self) -> &Engine
Available on crate feature runtime only.
pub fn engine(&self) -> &Engine
runtime only.Get the engine that this function type is associated with.
Sourcepub fn finality(&self) -> Finality
Available on crate feature runtime only.
pub fn finality(&self) -> Finality
runtime only.Get the finality of this function type.
Sourcepub fn supertype(&self) -> Option<Self>
Available on crate feature runtime only.
pub fn supertype(&self) -> Option<Self>
runtime only.Get the supertype of this function type, if any.
Sourcepub fn param(&self, i: usize) -> Option<ValType>
Available on crate feature runtime only.
pub fn param(&self, i: usize) -> Option<ValType>
runtime only.Get the ith parameter type.
Returns None if i is out of bounds.
Sourcepub fn params(&self) -> impl ExactSizeIterator<Item = ValType> + '_
Available on crate feature runtime only.
pub fn params(&self) -> impl ExactSizeIterator<Item = ValType> + '_
runtime only.Returns the list of parameter types for this function.
Sourcepub fn result(&self, i: usize) -> Option<ValType>
Available on crate feature runtime only.
pub fn result(&self, i: usize) -> Option<ValType>
runtime only.Get the ith result type.
Returns None if i is out of bounds.
Sourcepub fn results(&self) -> impl ExactSizeIterator<Item = ValType> + '_
Available on crate feature runtime only.
pub fn results(&self) -> impl ExactSizeIterator<Item = ValType> + '_
runtime only.Returns the list of result types for this function.
Sourcepub fn matches(&self, other: &FuncType) -> bool
Available on crate feature runtime only.
pub fn matches(&self, other: &FuncType) -> bool
runtime only.Does this function type match the other function type?
That is, is this function type a subtype of the other function type?
§Panics
Panics if either type is associated with a different engine from the other.
Sourcepub fn eq(a: &FuncType, b: &FuncType) -> bool
Available on crate feature runtime only.
pub fn eq(a: &FuncType, b: &FuncType) -> bool
runtime only.Is function type a precisely equal to function type b?
Returns false even if a is a subtype of b or vice versa, if they
are not exactly the same function type.
§Panics
Panics if either type is associated with a different engine from the other.
Sourcepub fn default_value(&self, store: impl AsContextMut) -> Result<Func>
Available on crate feature runtime only.
pub fn default_value(&self, store: impl AsContextMut) -> Result<Func>
runtime only.Construct a func which returns results of default value, if each result type has a default value.
Trait Implementations§
Source§impl From<FuncType> for ExternType
Available on crate feature runtime only.
impl From<FuncType> for ExternType
runtime only.Source§fn from(ty: FuncType) -> ExternType
fn from(ty: FuncType) -> ExternType
Source§impl WasmFunc for FuncType
Available on crate features wave and runtime only.
impl WasmFunc for FuncType
wave and runtime only.Source§fn params(&self) -> Box<dyn Iterator<Item = Self::Type> + '_>
fn params(&self) -> Box<dyn Iterator<Item = Self::Type> + '_>
Source§fn results(&self) -> Box<dyn Iterator<Item = Self::Type> + '_>
fn results(&self) -> Box<dyn Iterator<Item = Self::Type> + '_>
Auto Trait Implementations§
impl Freeze for FuncType
impl !RefUnwindSafe for FuncType
impl Send for FuncType
impl Sync for FuncType
impl Unpin for FuncType
impl !UnwindSafe for FuncType
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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