[][src]Enum wasm_webidl_bindings::ast::FunctionBinding

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

Variants

Import(ImportBinding)Export(ExportBinding)

Methods

impl FunctionBinding[src]

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

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

impl FunctionBindingId for FunctionBinding[src]

impl Clone for FunctionBinding[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl From<ImportBinding> for FunctionBinding[src]

impl From<ExportBinding> for FunctionBinding[src]

impl PartialEq<FunctionBinding> for FunctionBinding[src]

impl Eq for FunctionBinding[src]

impl Debug for FunctionBinding[src]

Auto Trait Implementations

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]