Struct quickjs_runtime::esvalue::EsValueFacade [−][src]
pub struct EsValueFacade { /* fields omitted */ }Implementations
impl EsValueFacade[src]
impl EsValueFacade[src]pub fn stringify(&self) -> Result<String, EsError>[src]
stringify the value
pub fn as_js_value(
&mut self,
q_ctx: &QuickJsContext
) -> Result<JSValueRef, EsError>[src]
&mut self,
q_ctx: &QuickJsContext
) -> Result<JSValueRef, EsError>
convert the value to a JSValueRef
pub fn from_jsval(
q_ctx: &QuickJsContext,
value_ref: &JSValueRef
) -> Result<Self, EsError>[src]
q_ctx: &QuickJsContext,
value_ref: &JSValueRef
) -> Result<Self, EsError>
convert a JSValueRef to an EsValueFacade
pub fn get_str(&self) -> &str[src]
get the String value
pub fn get_i32(&self) -> i32[src]
get the i32 value
pub fn get_f64(&self) -> f64[src]
get the f64 value
pub fn get_boolean(&self) -> bool[src]
get the boolean value
pub fn get_array(&self) -> Result<Vec<EsValueFacade>, EsError>[src]
get the array value
pub fn get_object(&self) -> Result<HashMap<String, EsValueFacade>, EsError>[src]
get the object value
pub fn is_string(&self) -> bool[src]
check if the value is a String
pub fn is_i32(&self) -> bool[src]
check if the value is a i32
pub fn is_f64(&self) -> bool[src]
check if the value is a f64
pub fn is_boolean(&self) -> bool[src]
check if the value is a bool
pub fn is_object(&self) -> bool[src]
check if the value is an object
pub fn is_promise(&self) -> bool[src]
check if the value is a Promise
pub fn is_array(&self) -> bool[src]
check if the value is an array
pub fn is_function(&self) -> bool[src]
check if the value is an function
pub fn is_null(&self) -> bool[src]
check if the value is null
pub fn is_undefined(&self) -> bool[src]
check if the value is undefined
pub fn invoke_function_sync(
&self,
arguments: Vec<EsValueFacade>
) -> Result<EsValueFacade, EsError>[src]
&self,
arguments: Vec<EsValueFacade>
) -> Result<EsValueFacade, EsError>
invoke the Function represented by this EsValueFacade
pub async fn invoke_function(
&self,
arguments: Vec<EsValueFacade>
) -> Result<EsValueFacade, EsError>[src]
&self,
arguments: Vec<EsValueFacade>
) -> Result<EsValueFacade, EsError>
invoke the Function represented by this EsValueFacade
pub fn invoke_function_batch_sync(
&self,
arguments: Vec<Vec<EsValueFacade>>
) -> Vec<Result<EsValueFacade, EsError>>[src]
&self,
arguments: Vec<Vec<EsValueFacade>>
) -> Vec<Result<EsValueFacade, EsError>>
invoke a function multiple times with a different set of arguments
pub fn invoke_function_batch(
&self,
arguments: Vec<Vec<EsValueFacade>>
) -> Result<(), EsError>[src]
&self,
arguments: Vec<Vec<EsValueFacade>>
) -> Result<(), EsError>
invoke a function multiple times with a different set of arguments
pub fn get_promise_result_sync(&self) -> Result<EsValueFacade, EsValueFacade>[src]
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>>[src]
&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 quickjs_runtime::esscript::EsScript; 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(EsScript::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);
pub fn is_error(&self) -> bool[src]
pub fn get_error(&self) -> EsError[src]
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for EsValueFacade
impl !RefUnwindSafe for EsValueFacadeimpl Send for EsValueFacade
impl Send for EsValueFacadeimpl !Sync for EsValueFacade
impl !Sync for EsValueFacadeimpl Unpin for EsValueFacade
impl Unpin for EsValueFacadeimpl !UnwindSafe for EsValueFacade
impl !UnwindSafe for EsValueFacade