[−][src]Enum wasm_webidl_bindings::ast::FunctionBinding
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]
&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 valtype | To Web IDL Type |
---|---|
i32 , f32 , f64 , anyref | any |
i32 | long , long long , float , unrestricted float , double , unrestricted double |
f32 | unrestricted float , unrestricted double |
f64 | unrestricted 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 Type | To Wasm valtype |
---|---|
any | anyref |
byte , short , long | i32 |
byte , octet , short , unsigned short , float , unrestricted float | f32 |
byte , octet , short , unsigned short , long , unsigned long , float , unrestricted float , double , unrestricted double | f64 |
Trait Implementations
impl FunctionBindingId for FunctionBinding
[src]
type Id = Id<FunctionBinding>
fn wrap(id: Id<FunctionBinding>) -> Self::Id
[src]
fn get(ty: &FunctionBinding) -> Option<&Self>
[src]
fn get_mut(ty: &mut FunctionBinding) -> Option<&mut Self>
[src]
impl Clone for FunctionBinding
[src]
fn clone(&self) -> 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]
fn from(a: ImportBinding) -> Self
[src]
impl From<ExportBinding> for FunctionBinding
[src]
fn from(a: ExportBinding) -> Self
[src]
impl PartialEq<FunctionBinding> for FunctionBinding
[src]
fn eq(&self, other: &FunctionBinding) -> bool
[src]
fn ne(&self, other: &FunctionBinding) -> bool
[src]
impl Eq for FunctionBinding
[src]
impl Debug for FunctionBinding
[src]
Auto Trait Implementations
impl Sync for FunctionBinding
impl Send for FunctionBinding
impl Unpin for FunctionBinding
impl RefUnwindSafe for FunctionBinding
impl UnwindSafe for FunctionBinding
Blanket Implementations
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,