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]
impl JsValue
pub fn from_str(s: &str) -> JsValue
[src]
pub fn from_str(s: &str) -> JsValue
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.
pub fn from_f64(n: f64) -> JsValue
[src]
pub fn from_f64(n: f64) -> JsValue
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.
pub fn from_bool(b: bool) -> JsValue
[src]
pub fn from_bool(b: bool) -> JsValue
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.
pub fn undefined() -> JsValue
[src]
pub fn undefined() -> JsValue
Creates a new JS value representing undefined
.
pub fn null() -> JsValue
[src]
pub fn null() -> JsValue
Creates a new JS value representing null
.
pub fn symbol(description: Option<&str>) -> JsValue
[src]
pub fn symbol(description: Option<&str>) -> JsValue
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.
pub fn as_f64(&self) -> Option<f64>
[src]
pub fn as_f64(&self) -> Option<f64>
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
.
pub fn as_string(&self) -> Option<String>
[src]
pub fn as_string(&self) -> Option<String>
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
.
pub fn as_bool(&self) -> Option<bool>
[src]
pub fn as_bool(&self) -> Option<bool>
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
.
pub fn is_null(&self) -> bool
[src]
pub fn is_null(&self) -> bool
Tests whether this JS value is null
pub fn is_undefined(&self) -> bool
[src]
pub fn is_undefined(&self) -> bool
Tests whether this JS value is undefined
pub fn is_symbol(&self) -> bool
[src]
pub fn is_symbol(&self) -> bool
Tests whether the type of this JS value is symbol
Trait Implementations
impl IntoWasmAbi for JsValue
[src]
impl IntoWasmAbi for JsValue
impl FromWasmAbi for JsValue
[src]
impl FromWasmAbi for JsValue
impl<'a> IntoWasmAbi for &'a JsValue
[src]
impl<'a> IntoWasmAbi for &'a JsValue
impl RefFromWasmAbi for JsValue
[src]
impl RefFromWasmAbi for JsValue
type Abi = u32
type Anchor = ManuallyDrop<JsValue>
unsafe fn ref_from_abi(js: u32, _extra: &mut Stack) -> Self::Anchor
[src]
unsafe fn ref_from_abi(js: u32, _extra: &mut Stack) -> Self::Anchor
impl<'a> From<&'a str> for JsValue
[src]
impl<'a> From<&'a str> for JsValue
impl<'a> From<&'a String> for JsValue
[src]
impl<'a> From<&'a String> for JsValue
impl From<bool> for JsValue
[src]
impl From<bool> for JsValue
impl From<i8> for JsValue
[src]
impl From<i8> for JsValue
impl From<u8> for JsValue
[src]
impl From<u8> for JsValue
impl From<i16> for JsValue
[src]
impl From<i16> for JsValue
impl From<u16> for JsValue
[src]
impl From<u16> for JsValue
impl From<i32> for JsValue
[src]
impl From<i32> for JsValue
impl From<u32> for JsValue
[src]
impl From<u32> for JsValue
impl From<f32> for JsValue
[src]
impl From<f32> for JsValue
impl From<f64> for JsValue
[src]
impl From<f64> for JsValue
impl Clone for JsValue
[src]
impl Clone for JsValue
fn clone(&self) -> JsValue
[src]
fn clone(&self) -> JsValue
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Drop for JsValue
[src]
impl Drop for JsValue