pub struct QuickJsRealmAdapter {
    pub id: String,
    pub context: *mut JSContext,
    /* private fields */
}

Fields§

§id: String§context: *mut JSContext

Implementations§

source§

impl QuickJsRealmAdapter

source

pub unsafe fn get_id(context: *mut JSContext) -> &'static str

get the id of a QuickJsContext from a JSContext

Safety

when passing a context ptr please be sure that the corresponding QuickJsContext is still active

source

pub fn invoke_function_by_name( &self, namespace: &[&str], func_name: &str, arguments: &[QuickJsValueAdapter] ) -> Result<QuickJsValueAdapter, JsError>

invoke a function by namespace and name

source

pub fn eval(&self, script: Script) -> Result<QuickJsValueAdapter, JsError>

evaluate a script

source

pub fn eval_this( &self, script: Script, this: QuickJsValueAdapter ) -> Result<QuickJsValueAdapter, JsError>

source

pub unsafe fn eval_ctx( context: *mut JSContext, script: Script, this_opt: Option<QuickJsValueAdapter> ) -> Result<QuickJsValueAdapter, JsError>

Safety

when passing a context ptr please be sure that the corresponding QuickJsContext is still active

source

pub fn eval_module( &self, script: Script ) -> Result<QuickJsValueAdapter, JsError>

evaluate a Module

source

pub unsafe fn eval_module_ctx( context: *mut JSContext, script: Script ) -> Result<QuickJsValueAdapter, JsError>

Safety

when passing a context ptr please be sure that the corresponding QuickJsContext is still active

source

pub fn report_ex(&self, err: &str) -> JSValue

throw an internal error to quickjs and create a new ex obj

source

pub unsafe fn report_ex_ctx(context: *mut JSContext, err: &str) -> JSValue

throw an Error in the runtime and init an Exception JSValue to return

Safety

when passing a context ptr please be sure that the corresponding QuickJsContext is still active

source

pub fn get_exception_ctx(&self) -> Option<JsError>

Get the last exception from the runtime, and if present, convert it to a JsError.

source

pub unsafe fn get_exception(context: *mut JSContext) -> Option<JsError>

Get the last exception from the runtime, and if present, convert it to a JsError.

Safety

When passing a context pointer please make sure the corresponding QuickJsContext is still valid

source

pub fn cache_object(&self, obj: QuickJsValueAdapter) -> i32

source

pub fn remove_cached_obj_if_present(&self, id: i32)

source

pub fn consume_cached_obj(&self, id: i32) -> QuickJsValueAdapter

source

pub fn with_cached_obj<C, R>(&self, id: i32, consumer: C) -> Rwhere C: FnOnce(QuickJsValueAdapter) -> R,

source

pub unsafe fn with_context<C, R>(context: *mut JSContext, consumer: C) -> Rwhere C: FnOnce(&QuickJsRealmAdapter) -> R,

Safety

When passing a context pointer please make sure the corresponding QuickJsContext is still valid

source§

impl QuickJsRealmAdapter

source

pub fn get_realm_id(&self) -> &str

source

pub fn get_runtime_facade_inner(&self) -> Weak<QuickjsRuntimeFacadeInner>

source

pub fn get_script_or_module_name(&self) -> Result<String, JsError>

source

pub fn install_proxy( &self, proxy: JsProxy, add_global_var: bool ) -> Result<QuickJsValueAdapter, JsError>

source

pub fn instantiate_proxy_with_id( &self, namespace: &[&str], class_name: &str, instance_id: usize ) -> Result<QuickJsValueAdapter, JsError>

source

pub fn instantiate_proxy( &self, namespace: &[&str], class_name: &str, arguments: &[QuickJsValueAdapter] ) -> Result<(JsProxyInstanceId, QuickJsValueAdapter), JsError>

source

pub fn dispatch_proxy_event( &self, namespace: &[&str], class_name: &str, proxy_instance_id: &usize, event_id: &str, event_obj: &QuickJsValueAdapter ) -> Result<bool, JsError>

source

pub fn dispatch_static_proxy_event( &self, namespace: &[&str], class_name: &str, event_id: &str, event_obj: &QuickJsValueAdapter ) -> Result<bool, JsError>

source

pub fn install_function( &self, namespace: &[&str], name: &str, js_function: fn(_: &QuickJsRuntimeAdapter, _: &Self, _: &QuickJsValueAdapter, _: &[QuickJsValueAdapter]) -> Result<QuickJsValueAdapter, JsError>, arg_count: u32 ) -> Result<(), JsError>

source

pub fn install_closure<F: Fn(&QuickJsRuntimeAdapter, &Self, &QuickJsValueAdapter, &[QuickJsValueAdapter]) -> Result<QuickJsValueAdapter, JsError> + 'static>( &self, namespace: &[&str], name: &str, js_function: F, arg_count: u32 ) -> Result<(), JsError>

source

pub fn get_global(&self) -> Result<QuickJsValueAdapter, JsError>

source

pub fn get_namespace( &self, namespace: &[&str] ) -> Result<QuickJsValueAdapter, JsError>

source

pub fn invoke_function_on_object_by_name( &self, this_obj: &QuickJsValueAdapter, method_name: &str, args: &[QuickJsValueAdapter] ) -> Result<QuickJsValueAdapter, JsError>

source

pub fn invoke_function( &self, this_obj: Option<&QuickJsValueAdapter>, function_obj: &QuickJsValueAdapter, args: &[&QuickJsValueAdapter] ) -> Result<QuickJsValueAdapter, JsError>

source

pub fn create_function<F: Fn(&Self, &QuickJsValueAdapter, &[QuickJsValueAdapter]) -> Result<QuickJsValueAdapter, JsError> + 'static>( &self, name: &str, js_function: F, arg_count: u32 ) -> Result<QuickJsValueAdapter, JsError>

source

pub fn create_function_async<R, F>( &self, name: &str, js_function: F, arg_count: u32 ) -> Result<QuickJsValueAdapter, JsError>where Self: Sized + 'static, R: Future<Output = Result<JsValueFacade, JsError>> + Send + 'static, F: Fn(JsValueFacade, Vec<JsValueFacade>) -> R + 'static,

source

pub fn create_error( &self, name: &str, message: &str, stack: &str ) -> Result<QuickJsValueAdapter, JsError>

source

pub fn delete_object_property( &self, object: &QuickJsValueAdapter, property_name: &str ) -> Result<(), JsError>

source

pub fn set_object_property( &self, object: &QuickJsValueAdapter, property_name: &str, property: &QuickJsValueAdapter ) -> Result<(), JsError>

source

pub fn get_object_property( &self, object: &QuickJsValueAdapter, property_name: &str ) -> Result<QuickJsValueAdapter, JsError>

source

pub fn create_object(&self) -> Result<QuickJsValueAdapter, JsError>

source

pub fn construct_object( &self, constructor: &QuickJsValueAdapter, args: &[&QuickJsValueAdapter] ) -> Result<QuickJsValueAdapter, JsError>

source

pub fn get_object_properties( &self, object: &QuickJsValueAdapter ) -> Result<Vec<String>, JsError>

source

pub fn traverse_object<F, R>( &self, object: &QuickJsValueAdapter, visitor: F ) -> Result<Vec<R>, JsError>where F: Fn(&str, &QuickJsValueAdapter) -> Result<R, JsError>,

source

pub fn traverse_object_mut<F>( &self, object: &QuickJsValueAdapter, visitor: F ) -> Result<(), JsError>where F: FnMut(&str, &QuickJsValueAdapter) -> Result<(), JsError>,

source

pub fn get_array_element( &self, array: &QuickJsValueAdapter, index: u32 ) -> Result<QuickJsValueAdapter, JsError>

source

pub fn push_array_element( &self, array: &QuickJsValueAdapter, element: &QuickJsValueAdapter ) -> Result<u32, JsError>

push an element into an Array

source

pub fn set_array_element( &self, array: &QuickJsValueAdapter, index: u32, element: &QuickJsValueAdapter ) -> Result<(), JsError>

source

pub fn get_array_length( &self, array: &QuickJsValueAdapter ) -> Result<u32, JsError>

source

pub fn create_array(&self) -> Result<QuickJsValueAdapter, JsError>

source

pub fn traverse_array<F, R>( &self, array: &QuickJsValueAdapter, visitor: F ) -> Result<Vec<R>, JsError>where F: Fn(u32, &QuickJsValueAdapter) -> Result<R, JsError>,

source

pub fn traverse_array_mut<F>( &self, array: &QuickJsValueAdapter, visitor: F ) -> Result<(), JsError>where F: FnMut(u32, &QuickJsValueAdapter) -> Result<(), JsError>,

source

pub fn create_null(&self) -> Result<QuickJsValueAdapter, JsError>

source

pub fn create_undefined(&self) -> Result<QuickJsValueAdapter, JsError>

source

pub fn create_i32(&self, val: i32) -> Result<QuickJsValueAdapter, JsError>

source

pub fn create_string(&self, val: &str) -> Result<QuickJsValueAdapter, JsError>

source

pub fn create_boolean(&self, val: bool) -> Result<QuickJsValueAdapter, JsError>

source

pub fn create_f64(&self, val: f64) -> Result<QuickJsValueAdapter, JsError>

source

pub fn create_promise(&self) -> Result<QuickJsPromiseAdapter, JsError>

source

pub fn add_promise_reactions( &self, promise: &QuickJsValueAdapter, then: Option<QuickJsValueAdapter>, catch: Option<QuickJsValueAdapter>, finally: Option<QuickJsValueAdapter> ) -> Result<(), JsError>

source

pub fn cache_promise(&self, promise_ref: QuickJsPromiseAdapter) -> usize

source

pub fn consume_cached_promise(&self, id: usize) -> Option<QuickJsPromiseAdapter>

source

pub fn dispose_cached_object(&self, id: i32)

source

pub fn with_cached_object<C, R>(&self, id: i32, consumer: C) -> Rwhere C: FnOnce(&QuickJsValueAdapter) -> R,

source

pub fn consume_cached_object(&self, id: i32) -> QuickJsValueAdapter

source

pub fn is_instance_of( &self, object: &QuickJsValueAdapter, constructor: &QuickJsValueAdapter ) -> bool

source

pub fn json_stringify( &self, object: &QuickJsValueAdapter, opt_space: Option<&str> ) -> Result<String, JsError>

source

pub fn json_parse( &self, json_string: &str ) -> Result<QuickJsValueAdapter, JsError>

source

pub fn create_typed_array_uint8( &self, buffer: Vec<u8> ) -> Result<QuickJsValueAdapter, JsError>

source

pub fn create_typed_array_uint8_copy( &self, buffer: &[u8] ) -> Result<QuickJsValueAdapter, JsError>

source

pub fn detach_typed_array_buffer( &self, array: &QuickJsValueAdapter ) -> Result<Vec<u8>, JsError>

source

pub fn copy_typed_array_buffer( &self, array: &QuickJsValueAdapter ) -> Result<Vec<u8>, JsError>

source

pub fn get_proxy_instance_info( &self, obj: &QuickJsValueAdapter ) -> Result<(String, JsProxyInstanceId), JsError>where Self: Sized,

source

pub fn to_js_value_facade( &self, js_value: &QuickJsValueAdapter ) -> Result<JsValueFacade, JsError>where Self: Sized + 'static,

source

pub fn from_js_value_facade( &self, value_facade: JsValueFacade ) -> Result<QuickJsValueAdapter, JsError>where Self: Sized + 'static,

convert a JSValueFacade into a JSValueAdapter you need this to move values into the worker thread from a different thread (JSValueAdapter cannot leave the worker thread)

source

pub fn value_adapter_to_serde_value( &self, value_adapter: &QuickJsValueAdapter ) -> Result<Value, JsError>

source

pub fn serde_value_to_value_adapter( &self, value: Value ) -> Result<QuickJsValueAdapter, JsError>

source

pub fn create_resolving_promise_async<P, R: Send + 'static, M>( &self, producer: P, mapper: M ) -> Result<QuickJsValueAdapter, JsError>where P: Future<Output = Result<R, JsError>> + Send + 'static, M: FnOnce(&QuickJsRealmAdapter, R) -> Result<QuickJsValueAdapter, JsError> + Send + 'static, Self: Sized + 'static,

create a new Promise with a Future which will run async and then resolve or reject the promise the mapper is used to convert the result of the future into a JSValueAdapter

source

pub fn create_resolving_promise<P, R: Send + 'static, M>( &self, producer: P, mapper: M ) -> Result<QuickJsValueAdapter, JsError>where P: FnOnce() -> Result<R, JsError> + Send + 'static, M: FnOnce(&QuickJsRealmAdapter, R) -> Result<QuickJsValueAdapter, JsError> + Send + 'static, Self: Sized + 'static,

create a new Promise with a FnOnce producer which will run async and then resolve or reject the promise the mapper is used to convert the result of the future into a JSValueAdapter

Trait Implementations§

source§

impl Drop for QuickJsRealmAdapter

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

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

§

fn vzip(self) -> V