#[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 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