Struct quickjs_runtime::esvalue::EsValueFacade[][src]

pub struct EsValueFacade { /* fields omitted */ }

Implementations

impl EsValueFacade[src]

pub fn as_js_value(
    &mut self,
    q_ctx: &QuickJsContext
) -> Result<JSValueRef, EsError>
[src]

pub fn from_jsval(
    q_ctx: &QuickJsContext,
    value_ref: &JSValueRef
) -> Result<Self, EsError>
[src]

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) -> &Vec<EsValueFacade>[src]

get the array value

pub fn get_array_mut(&mut self) -> &mut Vec<EsValueFacade>[src]

pub fn get_object(&self) -> &HashMap<String, EsValueFacade>[src]

get the object value

pub fn get_object_mut(&mut self) -> &mut HashMap<String, EsValueFacade>[src]

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]

pub fn is_undefined(&self) -> bool[src]

pub fn invoke_function_sync(
    &self,
    arguments: Vec<EsValueFacade>
) -> Result<EsValueFacade, EsError>
[src]

invoke the Function represented by this EsValueFacade

pub async fn invoke_function(
    &self,
    arguments: Vec<EsValueFacade>
) -> Result<EsValueFacade, EsError>
[src]

invoke the Function represented by this EsValueFacade

pub fn invoke_function_batch_sync(
    &self,
    arguments: Vec<Vec<EsValueFacade>>
) -> Vec<Result<EsValueFacade, EsError>>
[src]

pub fn invoke_function_batch(
    &self,
    arguments: Vec<Vec<EsValueFacade>>
) -> Result<(), EsError>
[src]

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]

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);

Trait Implementations

impl Debug for EsValueFacade[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,