pub struct EsValueFacade { /* private fields */ }

Implementations

stringify the value

convert the value to a JSValueRef

convert a JSValueRef to an EsValueFacade

get the String value

get the i32 value

get the f64 value

get the boolean value

get the array value

get the object value

check if the value is a String

check if the value is a i32

check if the value is a f64

check if the value is a bool

check if the value is an object

check if the value is a Promise

check if the value is an array

check if the value is an function

check if the value is null

check if the value is undefined

invoke the Function represented by this EsValueFacade

invoke the Function represented by this EsValueFacade

invoke a function multiple times with a different set of arguments

invoke a function multiple times with a different set of arguments

get the result of a Promise, this method blocks until the Promise is fulfilled. The Result will be an Ok if the Promise was resolved or an Err if the Promise was rejected

wait for the result of a Promise async. The Result will be an Ok if the Promise was resolved or an Err if the Promise was rejected

Example
use quickjs_runtime::builder::QuickJsRuntimeBuilder;
use hirofa_utils::js_utils::Script;
use futures::executor::block_on;
use quickjs_runtime::esvalue::EsValueFacade;
pub async fn test_async(esvf: EsValueFacade) -> i32 {
   let prom_res = esvf.get_promise_result().await;
   let res_esvf = prom_res.ok().unwrap();
   return res_esvf.get_i32();
}

let rt = QuickJsRuntimeBuilder::new().build();
let esvf = rt.eval_sync(Script::new("test_async_prom,es", "(new Promise((resolve, reject) => {setTimeout(() => {resolve(1360)}, 1000);}));")).ok().expect("script failed");
let i = block_on(test_async(esvf));
assert_eq!(i, 1360);

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.