#[repr(C)]pub struct Val { /* private fields */ }Expand description
Val is a wrapper around emscripten’s EM_VAL type, which itself represents javascript objects
Implementations§
source§impl Val
impl Val
sourcepub fn take_ownership(v: EM_VAL) -> Self
pub fn take_ownership(v: EM_VAL) -> Self
Creates a Val from a raw handle. This can be used for retrieving values from JavaScript, where the JavaScript side should wrap a value with Emval.toHandle, pass it to Rust, and then Rust can use take_ownership to convert it to a Val instance
sourcepub fn module_property(s: &str) -> Self
pub fn module_property(s: &str) -> Self
Looks up a value by the provided name on the Emscripten Module object.
sourcepub fn call(&self, f: &str, args: &[&Val]) -> Val
pub fn call(&self, f: &str, args: &[&Val]) -> Val
Call a method associated with the JS object represented by the Val object
sourcepub fn set<T: Clone + Into<Val>, U: Clone + Into<Val>>(&self, prop: &T, val: &U)
pub fn set<T: Clone + Into<Val>, U: Clone + Into<Val>>(&self, prop: &T, val: &U)
Set a property
sourcepub fn release_ownership(&mut self) -> EM_VAL
pub fn release_ownership(&mut self) -> EM_VAL
Get and release ownership of the internal handle
sourcepub fn has_own_property(&self, key: &str) -> bool
pub fn has_own_property(&self, key: &str) -> bool
Checks if the JavaScript object has own (non-inherited) property with the specified name.
sourcepub fn as_bool(&self) -> bool
pub fn as_bool(&self) -> bool
Converts current value to a bool. This can be useful also to check if a returned object is valid
sourcepub fn is_undefined(&self) -> bool
pub fn is_undefined(&self) -> bool
Checks whether a value is undefined
sourcepub fn instanceof(&self, v: &Val) -> bool
pub fn instanceof(&self, v: &Val) -> bool
Checks whether the object is an instanceof another object
sourcepub fn is_in(&self, v: &Val) -> bool
pub fn is_in(&self, v: &Val) -> bool
Checks if the specified property is in the specified object
sourcepub fn await_(&self) -> Val
pub fn await_(&self) -> Val
Pauses the Rust code to await the Promise / thenable. This requires ASYNCIFY to be enabled
sourcepub fn new(&self, args: &[&Val]) -> Val
pub fn new(&self, args: &[&Val]) -> Val
Instantiate a new object, passes the args to the object’s contructor
sourcepub fn strictly_equals<T: Clone + Into<Val>>(&self, v: &T) -> bool
pub fn strictly_equals<T: Clone + Into<Val>>(&self, v: &T) -> bool
Check if the current object is strictly equals to another object ===
sourcepub fn add_event_listener<F: FnMut(&Val) -> Val + 'static>(
&self,
ev: &str,
f: F,
)
pub fn add_event_listener<F: FnMut(&Val) -> Val + 'static>( &self, ev: &str, f: F, )
Convenience method. Adds a callback to an EventTarget object
sourcepub fn from_fn0<F: FnMut() -> Val + 'static>(f: F) -> Val
pub fn from_fn0<F: FnMut() -> Val + 'static>(f: F) -> Val
Generates a Val object from a function object which takes 0 args
sourcepub fn from_fn1<F: FnMut(&Val) -> Val + 'static>(f: F) -> Val
pub fn from_fn1<F: FnMut(&Val) -> Val + 'static>(f: F) -> Val
Generates a Val object from a function object which takes 1 arg
sourcepub fn from_fn2<F: FnMut(&Val, &Val) -> Val + 'static>(f: F) -> Val
pub fn from_fn2<F: FnMut(&Val, &Val) -> Val + 'static>(f: F) -> Val
Generates a Val object from a function object which takes 2 args
sourcepub fn from_fn3<F: FnMut(&Val, &Val, &Val) -> Val + 'static>(f: F) -> Val
pub fn from_fn3<F: FnMut(&Val, &Val, &Val) -> Val + 'static>(f: F) -> Val
Generates a Val object from a function object which takes 3 args
Trait Implementations§
source§impl PartialOrd for Val
impl PartialOrd for Val
impl Eq for Val
Auto Trait Implementations§
impl Freeze for Val
impl RefUnwindSafe for Val
impl !Send for Val
impl !Sync for Val
impl Unpin for Val
impl UnwindSafe for Val
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)