Struct quickjs_runtime::esvalue::EsValueFacade [−][src]
pub struct EsValueFacade { /* fields omitted */ }Implementations
convert the value to a JSValueRef
convert a JSValueRef to an EsValueFacade
get the boolean value
get the object value
check if the value is a bool
check if the value is a Promise
check if the value is an function
check if the value is undefined
pub fn invoke_function_sync(
&self,
arguments: Vec<EsValueFacade>
) -> Result<EsValueFacade, JsError>
pub fn invoke_function_sync(
&self,
arguments: Vec<EsValueFacade>
) -> Result<EsValueFacade, JsError>invoke the Function represented by this EsValueFacade
pub async fn invoke_function(
&self,
arguments: Vec<EsValueFacade>
) -> Result<EsValueFacade, JsError>
pub async fn invoke_function(
&self,
arguments: Vec<EsValueFacade>
) -> Result<EsValueFacade, JsError>invoke the Function represented by this EsValueFacade
pub fn invoke_function_batch_sync(
&self,
arguments: Vec<Vec<EsValueFacade>>
) -> Vec<Result<EsValueFacade, JsError>>
pub fn invoke_function_batch_sync(
&self,
arguments: Vec<Vec<EsValueFacade>>
) -> Vec<Result<EsValueFacade, JsError>>invoke a function multiple times with a different set of arguments
pub fn invoke_function_batch(
&self,
arguments: Vec<Vec<EsValueFacade>>
) -> Result<(), JsError>
pub fn invoke_function_batch(
&self,
arguments: Vec<Vec<EsValueFacade>>
) -> Result<(), JsError>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
pub fn get_promise_result(
&self
) -> impl Future<Output = Result<EsValueFacade, EsValueFacade>>
pub fn get_promise_result(
&self
) -> impl Future<Output = Result<EsValueFacade, EsValueFacade>>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::esruntimebuilder::EsRuntimeBuilder; 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 = EsRuntimeBuilder::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
Auto Trait Implementations
impl !RefUnwindSafe for EsValueFacadeimpl Send for EsValueFacadeimpl !Sync for EsValueFacadeimpl Unpin for EsValueFacadeimpl !UnwindSafe for EsValueFacade