Struct wasm_bindgen::JsValue [] [src]

pub struct JsValue { /* fields omitted */ }

Representation of an object owned by JS.

A JsValue doesn't actually live in Rust right now but actually in a table owned by the wasm-bindgen generated JS glue code. Eventually the ownership will transfer into wasm directly and this will likely become more efficient, but for now it may be slightly slow.

Methods

impl JsValue
[src]

[src]

Creates a new JS value which is a string.

The utf-8 string provided is copied to the JS heap and the string will be owned by the JS garbage collector.

[src]

Creates a new JS value which is a number.

This function creates a JS value representing a number (a heap allocated number) and returns a handle to the JS version of it.

[src]

Creates a new JS value which is a boolean.

This function creates a JS object representing a boolean (a heap allocated boolean) and returns a handle to the JS version of it.

[src]

Creates a new JS value representing undefined.

[src]

Creates a new JS value representing null.

[src]

Creates a new JS symbol with the optional description specified.

This function will invoke the Symbol constructor in JS and return the JS object corresponding to the symbol created.

[src]

Returns the f64 value of this JS value if it's an instance of a number.

If this JS value is not an instance of a number then this returns None.

[src]

Returns the String of this JS value if it's an instance of a string and it's valid utf-8.

If this JS value is not an instance of a string or if it's not valid utf-8 then this returns None.

[src]

Returns the bool value of this JS value if it's an instance of a boolean.

If this JS value is not an instance of a boolean then this returns None.

[src]

Tests whether this JS value is null

[src]

Tests whether this JS value is undefined

[src]

Tests whether the type of this JS value is symbol

Trait Implementations

impl WasmBoundary for JsValue
[src]

DESCRIPTOR: u32 = DESCRIPTOR_JS_OWNED

[src]

[src]

impl ToRefWasmBoundary for JsValue
[src]

[src]

impl FromRefWasmBoundary for JsValue
[src]

impl<'a> From<&'a str> for JsValue
[src]

[src]

Performs the conversion.

impl<'a> From<&'a String> for JsValue
[src]

[src]

Performs the conversion.

impl From<bool> for JsValue
[src]

[src]

Performs the conversion.

impl From<i8> for JsValue
[src]

[src]

Performs the conversion.

impl From<u8> for JsValue
[src]

[src]

Performs the conversion.

impl From<i16> for JsValue
[src]

[src]

Performs the conversion.

impl From<u16> for JsValue
[src]

[src]

Performs the conversion.

impl From<i32> for JsValue
[src]

[src]

Performs the conversion.

impl From<u32> for JsValue
[src]

[src]

Performs the conversion.

impl From<f32> for JsValue
[src]

[src]

Performs the conversion.

impl From<f64> for JsValue
[src]

[src]

Performs the conversion.

impl Clone for JsValue
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Drop for JsValue
[src]

[src]

Executes the destructor for this type. Read more

Auto Trait Implementations

impl Send for JsValue

impl Sync for JsValue