[−][src]Struct wasm_bindgen::JsValue
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 const NULL: JsValue[src]
The null JS value constant.
pub const UNDEFINED: JsValue[src]
The undefined JS value constant.
pub const TRUE: JsValue[src]
The true JS value constant.
pub const FALSE: JsValue[src]
The false JS value constant.
pub 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 is_string(&self) -> bool[src]
pub fn is_string(&self) -> boolTests whether this JS value is a JS string.
pub fn as_string(&self) -> Option<String>[src]
pub fn as_string(&self) -> Option<String>If this JS value is a string value, this function copies the JS string
value into wasm linear memory, encoded as UTF-8, and returns it as a
Rust String.
To avoid the copying and re-encoding, consider the
JsString::try_from() function from js-sys
instead.
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
pub fn is_object(&self) -> bool[src]
pub fn is_object(&self) -> boolTests whether typeof self == "object" && self !== null.
pub fn is_function(&self) -> bool[src]
pub fn is_function(&self) -> boolTests whether the type of this JS value is function.
Trait Implementations
impl IntoWasmAbi for JsValue[src]
impl IntoWasmAbi for JsValuetype Abi = u32
The wasm ABI type that this converts into when crossing the ABI boundary. Read more
fn into_abi(self, _extra: &mut dyn Stack) -> u32[src]
fn into_abi(self, _extra: &mut dyn Stack) -> u32impl<'a> IntoWasmAbi for &'a JsValue[src]
impl<'a> IntoWasmAbi for &'a JsValuetype Abi = u32
The wasm ABI type that this converts into when crossing the ABI boundary. Read more
fn into_abi(self, _extra: &mut dyn Stack) -> u32[src]
fn into_abi(self, _extra: &mut dyn Stack) -> u32impl FromWasmAbi for JsValue[src]
impl FromWasmAbi for JsValuetype Abi = u32
The wasm ABI type that this converts from when coming back out from the ABI boundary. Read more
unsafe fn from_abi(js: u32, _extra: &mut dyn Stack) -> JsValue[src]
unsafe fn from_abi(js: u32, _extra: &mut dyn Stack) -> JsValueimpl RefFromWasmAbi for JsValue[src]
impl RefFromWasmAbi for JsValuetype Abi = u32
The wasm ABI type references to Self are recovered from.
type Anchor = ManuallyDrop<JsValue>
The type that holds the reference to Self for the duration of the invocation of the function that has an &Self parameter. This is required to ensure that the lifetimes don't persist beyond one function call, and so that they remain anonymous. Read more
unsafe fn ref_from_abi(js: u32, _extra: &mut dyn Stack) -> Self::Anchor[src]
unsafe fn ref_from_abi(js: u32, _extra: &mut dyn Stack) -> Self::Anchorimpl JsCast for JsValue[src]
impl JsCast for JsValuefn instanceof(_val: &JsValue) -> bool[src]
fn instanceof(_val: &JsValue) -> boolfn unchecked_from_js(val: JsValue) -> Self[src]
fn unchecked_from_js(val: JsValue) -> Selffn unchecked_from_js_ref(val: &JsValue) -> &Self[src]
fn unchecked_from_js_ref(val: &JsValue) -> &Selffn is_instance_of<T>(&self) -> bool where
T: JsCast, [src]
fn is_instance_of<T>(&self) -> bool where
T: JsCast, Test whether this JS value is an instance of the type T. Read more
fn dyn_into<T>(self) -> Result<T, Self> where
T: JsCast, [src]
fn dyn_into<T>(self) -> Result<T, Self> where
T: JsCast, Performs a dynamic cast (checked at runtime) of this value into the target type T. Read more
fn dyn_ref<T>(&self) -> Option<&T> where
T: JsCast, [src]
fn dyn_ref<T>(&self) -> Option<&T> where
T: JsCast, Performs a dynamic cast (checked at runtime) of this value into the target type T. Read more
fn unchecked_into<T>(self) -> T where
T: JsCast, [src]
fn unchecked_into<T>(self) -> T where
T: JsCast, Performs a zero-cost unchecked cast into the specified type. Read more
fn unchecked_ref<T>(&self) -> &T where
T: JsCast, [src]
fn unchecked_ref<T>(&self) -> &T where
T: JsCast, Performs a zero-cost unchecked cast into a reference to the specified type. Read more
impl Debug for JsValue[src]
impl Debug for JsValueimpl PartialEq<JsValue> for JsValue[src]
impl PartialEq<JsValue> for JsValuefn eq(&self, other: &JsValue) -> bool[src]
fn eq(&self, other: &JsValue) -> bool#[must_use]
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn ne(&self, other: &Rhs) -> boolThis method tests for !=.
impl PartialEq<bool> for JsValue[src]
impl PartialEq<bool> for JsValuefn eq(&self, other: &bool) -> bool[src]
fn eq(&self, other: &bool) -> bool#[must_use]
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn ne(&self, other: &Rhs) -> boolThis method tests for !=.
impl PartialEq<str> for JsValue[src]
impl PartialEq<str> for JsValuefn eq(&self, other: &str) -> bool[src]
fn eq(&self, other: &str) -> bool#[must_use]
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn ne(&self, other: &Rhs) -> boolThis method tests for !=.
impl<'a> PartialEq<&'a str> for JsValue[src]
impl<'a> PartialEq<&'a str> for JsValuefn eq(&self, other: &&'a str) -> bool[src]
fn eq(&self, other: &&'a str) -> bool#[must_use]
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn ne(&self, other: &Rhs) -> boolThis method tests for !=.
impl PartialEq<String> for JsValue[src]
impl PartialEq<String> for JsValuefn eq(&self, other: &String) -> bool[src]
fn eq(&self, other: &String) -> bool#[must_use]
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn ne(&self, other: &Rhs) -> boolThis method tests for !=.
impl<'a> PartialEq<&'a String> for JsValue[src]
impl<'a> PartialEq<&'a String> for JsValuefn eq(&self, other: &&'a String) -> bool[src]
fn eq(&self, other: &&'a String) -> bool#[must_use]
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn ne(&self, other: &Rhs) -> boolThis method tests for !=.
impl PartialEq<i8> for JsValue[src]
impl PartialEq<i8> for JsValuefn eq(&self, other: &i8) -> bool[src]
fn eq(&self, other: &i8) -> bool#[must_use]
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn ne(&self, other: &Rhs) -> boolThis method tests for !=.
impl PartialEq<u8> for JsValue[src]
impl PartialEq<u8> for JsValuefn eq(&self, other: &u8) -> bool[src]
fn eq(&self, other: &u8) -> bool#[must_use]
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn ne(&self, other: &Rhs) -> boolThis method tests for !=.
impl PartialEq<i16> for JsValue[src]
impl PartialEq<i16> for JsValuefn eq(&self, other: &i16) -> bool[src]
fn eq(&self, other: &i16) -> bool#[must_use]
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn ne(&self, other: &Rhs) -> boolThis method tests for !=.
impl PartialEq<u16> for JsValue[src]
impl PartialEq<u16> for JsValuefn eq(&self, other: &u16) -> bool[src]
fn eq(&self, other: &u16) -> bool#[must_use]
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn ne(&self, other: &Rhs) -> boolThis method tests for !=.
impl PartialEq<i32> for JsValue[src]
impl PartialEq<i32> for JsValuefn eq(&self, other: &i32) -> bool[src]
fn eq(&self, other: &i32) -> bool#[must_use]
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn ne(&self, other: &Rhs) -> boolThis method tests for !=.
impl PartialEq<u32> for JsValue[src]
impl PartialEq<u32> for JsValuefn eq(&self, other: &u32) -> bool[src]
fn eq(&self, other: &u32) -> bool#[must_use]
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn ne(&self, other: &Rhs) -> boolThis method tests for !=.
impl PartialEq<f32> for JsValue[src]
impl PartialEq<f32> for JsValuefn eq(&self, other: &f32) -> bool[src]
fn eq(&self, other: &f32) -> bool#[must_use]
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn ne(&self, other: &Rhs) -> boolThis method tests for !=.
impl PartialEq<f64> for JsValue[src]
impl PartialEq<f64> for JsValuefn eq(&self, other: &f64) -> bool[src]
fn eq(&self, other: &f64) -> bool#[must_use]
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn ne(&self, other: &Rhs) -> boolThis method tests for !=.
impl Drop for JsValue[src]
impl Drop for JsValueimpl<'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<String> for JsValue[src]
impl From<String> for JsValueimpl From<bool> for JsValue[src]
impl From<bool> for JsValueimpl<'a, T> From<&'a T> for JsValue where
T: JsCast, [src]
impl<'a, T> From<&'a T> for JsValue where
T: JsCast, impl<T> From<Option<T>> for JsValue where
JsValue: From<T>, [src]
impl<T> From<Option<T>> for JsValue where
JsValue: From<T>, impl 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) -> JsValuefn 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<T: ?Sized> AsRef<JsValue> for Closure<T>[src]
impl<T: ?Sized> AsRef<JsValue> for Closure<T>impl AsRef<JsValue> for JsValue[src]
impl AsRef<JsValue> for JsValueAuto Trait Implementations
Blanket Implementations
impl<T, U> TryFrom for T where
T: From<U>, [src]
impl<T, U> TryFrom for T where
T: From<U>, type Error = !
try_from)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>impl<T> From for T[src]
impl<T> From for Timpl<T, U> TryInto for T where
U: TryFrom<T>, [src]
impl<T, U> TryInto for T where
U: TryFrom<T>, type Error = <U as TryFrom<T>>::Error
try_from)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>impl<T, U> Into for T where
U: From<T>, [src]
impl<T, U> Into for T where
U: From<T>, impl<T> Borrow for T where
T: ?Sized, [src]
impl<T> Borrow for T where
T: ?Sized, impl<T> BorrowMut for T where
T: ?Sized, [src]
impl<T> BorrowMut for T where
T: ?Sized, fn borrow_mut(&mut self) -> &mut T[src]
fn borrow_mut(&mut self) -> &mut Timpl<T> Any for T where
T: 'static + ?Sized, [src]
impl<T> Any for T where
T: 'static + ?Sized, fn get_type_id(&self) -> TypeId[src]
fn get_type_id(&self) -> TypeIdimpl<T> ToOwned for T where
T: Clone, [src]
impl<T> ToOwned for T where
T: Clone,