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 JsValuepub fn from_str(s: &str) -> JsValue[src]
pub fn from_str(s: &str) -> JsValueCreates 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) -> JsValueCreates 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) -> JsValueCreates 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() -> JsValueCreates a new JS value representing undefined.
pub fn null() -> JsValue[src]
pub fn null() -> JsValueCreates a new JS value representing null.
pub fn symbol(description: Option<&str>) -> JsValue[src]
pub fn symbol(description: Option<&str>) -> JsValueCreates 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) -> boolTests whether this JS value is null
pub fn is_undefined(&self) -> bool[src]
pub fn is_undefined(&self) -> boolTests whether this JS value is undefined
pub fn is_symbol(&self) -> bool[src]
pub fn is_symbol(&self) -> boolTests whether the type of this JS value is symbol
Trait Implementations
impl IntoWasmAbi for JsValue[src]
impl IntoWasmAbi for JsValueimpl FromWasmAbi for JsValue[src]
impl FromWasmAbi for JsValueimpl<'a> IntoWasmAbi for &'a JsValue[src]
impl<'a> IntoWasmAbi for &'a JsValueimpl RefFromWasmAbi for JsValue[src]
impl RefFromWasmAbi for JsValuetype 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::Anchorimpl<'a> From<&'a str> for JsValue[src]
impl<'a> From<&'a str> for JsValueimpl<'a> From<&'a String> for JsValue[src]
impl<'a> From<&'a String> for JsValueimpl From<bool> for JsValue[src]
impl From<bool> for JsValueimpl From<i8> for JsValue[src]
impl From<i8> for JsValueimpl From<u8> for JsValue[src]
impl From<u8> for JsValueimpl From<i16> for JsValue[src]
impl From<i16> for JsValueimpl From<u16> for JsValue[src]
impl From<u16> for JsValueimpl From<i32> for JsValue[src]
impl From<i32> for JsValueimpl From<u32> for JsValue[src]
impl From<u32> for JsValueimpl From<f32> for JsValue[src]
impl From<f32> for JsValueimpl From<f64> for JsValue[src]
impl From<f64> for JsValueimpl Clone for JsValue[src]
impl Clone for JsValuefn clone(&self) -> JsValue[src]
fn clone(&self) -> JsValueReturns 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