Enum FunctionBinding

Source
pub enum FunctionBinding {
    Import(ImportBinding),
    Export(ExportBinding),
}

Variants§

Implementations§

Source§

impl FunctionBinding

Source

pub fn is_expressible_in_js_without_webidl_bindings( &self, module: &Module, wb: &WebidlBindings, ) -> bool

In the context of a JS embedder that does not implement the Web IDL bindings proposal, are this binding’s ingoing and outgoing conversions losslessly expressible with the default conversions of the WebAssembly JavaScript interface and the ECMAScript bindings for Web IDL?

This is primarily a question that is only relevant to polyfills for Web IDL bindings, such as wasm-bindgen.

For both incoming and outgoing values, the conversions are not expressible if each value is referenced more than once in the binding map, or the values are referenced out of order. Failure to meet this criteria would result in swapped, garbage, extra, or not enough parameters/results.

In addition to the arity and usage requirements, each value’s type must also be trivially convertible. This property depends on whether the value is incoming or outgoing.

§Outgoing Values

When passing outgoing Wasm values to Web IDL, first they are converted to JS values via the ToJSValue algorithm defined by the WebAssembly JavaScript interface. Next, these JS values then they are converted into Web IDL values via Web IDL’s ECMAScript type mapping.

+------------+                                 +----------+                                        +---------------+
| Wasm value | ---WebAssembly-JS-interface---> | JS value | ---ECMAScript-bindings-for-Web-IDL---> | Web IDL value |
+------------+                                 +----------+                                        +---------------+

For outgoing values to be expressible without Web IDL bindings, nor extra glue or conversions, they must be an as operator performing on of the following conversions from a Wasm value type to a Web IDL type:

From Wasm valtypeTo Web IDL Type
i32, f32, f64, anyrefany
i32long, long long, float, unrestricted float, double, unrestricted double
f32unrestricted float, unrestricted double
f64unrestricted double
§Incoming Values

When passing Web IDL values to Wasm, first they are converted to JS values via the Web IDL’s ECMAScript type mapping, and then those JS values are converted into Wasm values according to the ToWebAssemblyValue algorithm defined by the WebAssembly JavaScript interface.

+---------------+                                         +----------+                                 +---------------+
| Web IDL value |  ---ECMAScript-bindings-for-Web-IDL---> | JS value | ---WebAssembly-JS-interface---> | Web IDL value |
+---------------+                                         +----------+                                 +---------------+

For incoming values to be expressible without Web IDL bindings, nor extra glue or conversions, they must be an incoming binding expression of the form (as (get <i>)) that is performing one of the following conversions from a Web IDL type to a Wasm type:

From Web IDL TypeTo Wasm valtype
anyanyref
byte, short, longi32
byte, octet, short, unsigned short, float, unrestricted floatf32
byte, octet, short, unsigned short, long, unsigned long, float, unrestricted float, double, unrestricted doublef64

Trait Implementations§

Source§

impl Clone for FunctionBinding

Source§

fn clone(&self) -> FunctionBinding

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
Source§

impl Debug for FunctionBinding

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<ExportBinding> for FunctionBinding

Source§

fn from(a: ExportBinding) -> Self

Converts to this type from the input type.
Source§

impl From<ImportBinding> for FunctionBinding

Source§

fn from(a: ImportBinding) -> Self

Converts to this type from the input type.
Source§

impl FunctionBindingId for FunctionBinding

Source§

impl PartialEq for FunctionBinding

Source§

fn eq(&self, other: &FunctionBinding) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for FunctionBinding

Source§

impl StructuralPartialEq for FunctionBinding

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> 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.

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> 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.