pub struct QuickJsRealmAdapter {
pub id: String,
pub context: *mut JSContext,
/* private fields */
}
Fields§
§id: String
§context: *mut JSContext
Implementations§
source§impl QuickJsRealmAdapter
impl QuickJsRealmAdapter
pub fn print_stats(&self)
sourcepub unsafe fn get_id(context: *mut JSContext) -> &'static str
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
sourcepub fn invoke_function_by_name(
&self,
namespace: &[&str],
func_name: &str,
arguments: &[QuickJsValueAdapter]
) -> Result<QuickJsValueAdapter, JsError>
pub fn invoke_function_by_name( &self, namespace: &[&str], func_name: &str, arguments: &[QuickJsValueAdapter] ) -> Result<QuickJsValueAdapter, JsError>
invoke a function by namespace and name
pub fn eval_this( &self, script: Script, this: QuickJsValueAdapter ) -> Result<QuickJsValueAdapter, JsError>
sourcepub unsafe fn eval_ctx(
context: *mut JSContext,
script: Script,
this_opt: Option<QuickJsValueAdapter>
) -> Result<QuickJsValueAdapter, JsError>
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
sourcepub fn eval_module(
&self,
script: Script
) -> Result<QuickJsValueAdapter, JsError>
pub fn eval_module( &self, script: Script ) -> Result<QuickJsValueAdapter, JsError>
evaluate a Module
sourcepub unsafe fn eval_module_ctx(
context: *mut JSContext,
script: Script
) -> Result<QuickJsValueAdapter, JsError>
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
sourcepub fn report_ex(&self, err: &str) -> JSValue
pub fn report_ex(&self, err: &str) -> JSValue
throw an internal error to quickjs and create a new ex obj
sourcepub unsafe fn report_ex_ctx(context: *mut JSContext, err: &str) -> JSValue
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
sourcepub fn get_exception_ctx(&self) -> Option<JsError>
pub fn get_exception_ctx(&self) -> Option<JsError>
Get the last exception from the runtime, and if present, convert it to a JsError.
sourcepub unsafe fn get_exception(context: *mut JSContext) -> Option<JsError>
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
pub fn cache_object(&self, obj: QuickJsValueAdapter) -> i32
pub fn remove_cached_obj_if_present(&self, id: i32)
pub fn consume_cached_obj(&self, id: i32) -> QuickJsValueAdapter
pub fn with_cached_obj<C, R>(&self, id: i32, consumer: C) -> Rwhere
C: FnOnce(QuickJsValueAdapter) -> R,
sourcepub unsafe fn with_context<C, R>(context: *mut JSContext, consumer: C) -> Rwhere
C: FnOnce(&QuickJsRealmAdapter) -> R,
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
impl QuickJsRealmAdapter
pub fn get_realm_id(&self) -> &str
pub fn get_runtime_facade_inner(&self) -> Weak<QuickjsRuntimeFacadeInner>
pub fn get_script_or_module_name(&self) -> Result<String, JsError>
pub fn install_proxy( &self, proxy: JsProxy, add_global_var: bool ) -> Result<QuickJsValueAdapter, JsError>
pub fn instantiate_proxy_with_id( &self, namespace: &[&str], class_name: &str, instance_id: usize ) -> Result<QuickJsValueAdapter, JsError>
pub fn instantiate_proxy( &self, namespace: &[&str], class_name: &str, arguments: &[QuickJsValueAdapter] ) -> Result<(JsProxyInstanceId, QuickJsValueAdapter), JsError>
pub fn dispatch_proxy_event( &self, namespace: &[&str], class_name: &str, proxy_instance_id: &usize, event_id: &str, event_obj: &QuickJsValueAdapter ) -> Result<bool, JsError>
pub fn dispatch_static_proxy_event( &self, namespace: &[&str], class_name: &str, event_id: &str, event_obj: &QuickJsValueAdapter ) -> Result<bool, JsError>
pub fn install_function( &self, namespace: &[&str], name: &str, js_function: fn(_: &QuickJsRuntimeAdapter, _: &Self, _: &QuickJsValueAdapter, _: &[QuickJsValueAdapter]) -> Result<QuickJsValueAdapter, JsError>, arg_count: u32 ) -> Result<(), JsError>
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>
pub fn get_global(&self) -> Result<QuickJsValueAdapter, JsError>
pub fn get_namespace( &self, namespace: &[&str] ) -> Result<QuickJsValueAdapter, JsError>
pub fn invoke_function_on_object_by_name( &self, this_obj: &QuickJsValueAdapter, method_name: &str, args: &[QuickJsValueAdapter] ) -> Result<QuickJsValueAdapter, JsError>
pub fn invoke_function( &self, this_obj: Option<&QuickJsValueAdapter>, function_obj: &QuickJsValueAdapter, args: &[&QuickJsValueAdapter] ) -> Result<QuickJsValueAdapter, JsError>
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>
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,
pub fn create_error( &self, name: &str, message: &str, stack: &str ) -> Result<QuickJsValueAdapter, JsError>
pub fn delete_object_property( &self, object: &QuickJsValueAdapter, property_name: &str ) -> Result<(), JsError>
pub fn set_object_property( &self, object: &QuickJsValueAdapter, property_name: &str, property: &QuickJsValueAdapter ) -> Result<(), JsError>
pub fn get_object_property( &self, object: &QuickJsValueAdapter, property_name: &str ) -> Result<QuickJsValueAdapter, JsError>
pub fn create_object(&self) -> Result<QuickJsValueAdapter, JsError>
pub fn construct_object( &self, constructor: &QuickJsValueAdapter, args: &[&QuickJsValueAdapter] ) -> Result<QuickJsValueAdapter, JsError>
pub fn get_object_properties( &self, object: &QuickJsValueAdapter ) -> Result<Vec<String>, JsError>
pub fn traverse_object<F, R>( &self, object: &QuickJsValueAdapter, visitor: F ) -> Result<Vec<R>, JsError>
pub fn traverse_object_mut<F>( &self, object: &QuickJsValueAdapter, visitor: F ) -> Result<(), JsError>
pub fn get_array_element( &self, array: &QuickJsValueAdapter, index: u32 ) -> Result<QuickJsValueAdapter, JsError>
sourcepub fn push_array_element(
&self,
array: &QuickJsValueAdapter,
element: &QuickJsValueAdapter
) -> Result<u32, JsError>
pub fn push_array_element( &self, array: &QuickJsValueAdapter, element: &QuickJsValueAdapter ) -> Result<u32, JsError>
push an element into an Array
pub fn set_array_element( &self, array: &QuickJsValueAdapter, index: u32, element: &QuickJsValueAdapter ) -> Result<(), JsError>
pub fn get_array_length( &self, array: &QuickJsValueAdapter ) -> Result<u32, JsError>
pub fn create_array(&self) -> Result<QuickJsValueAdapter, JsError>
pub fn traverse_array<F, R>( &self, array: &QuickJsValueAdapter, visitor: F ) -> Result<Vec<R>, JsError>
pub fn traverse_array_mut<F>( &self, array: &QuickJsValueAdapter, visitor: F ) -> Result<(), JsError>
pub fn create_null(&self) -> Result<QuickJsValueAdapter, JsError>
pub fn create_undefined(&self) -> Result<QuickJsValueAdapter, JsError>
pub fn create_i32(&self, val: i32) -> Result<QuickJsValueAdapter, JsError>
pub fn create_string(&self, val: &str) -> Result<QuickJsValueAdapter, JsError>
pub fn create_boolean(&self, val: bool) -> Result<QuickJsValueAdapter, JsError>
pub fn create_f64(&self, val: f64) -> Result<QuickJsValueAdapter, JsError>
pub fn create_promise(&self) -> Result<QuickJsPromiseAdapter, JsError>
pub fn add_promise_reactions( &self, promise: &QuickJsValueAdapter, then: Option<QuickJsValueAdapter>, catch: Option<QuickJsValueAdapter>, finally: Option<QuickJsValueAdapter> ) -> Result<(), JsError>
pub fn cache_promise(&self, promise_ref: QuickJsPromiseAdapter) -> usize
pub fn consume_cached_promise(&self, id: usize) -> Option<QuickJsPromiseAdapter>
pub fn dispose_cached_object(&self, id: i32)
pub fn with_cached_object<C, R>(&self, id: i32, consumer: C) -> Rwhere
C: FnOnce(&QuickJsValueAdapter) -> R,
pub fn consume_cached_object(&self, id: i32) -> QuickJsValueAdapter
pub fn is_instance_of( &self, object: &QuickJsValueAdapter, constructor: &QuickJsValueAdapter ) -> bool
pub fn json_stringify( &self, object: &QuickJsValueAdapter, opt_space: Option<&str> ) -> Result<String, JsError>
pub fn json_parse( &self, json_string: &str ) -> Result<QuickJsValueAdapter, JsError>
pub fn create_typed_array_uint8( &self, buffer: Vec<u8> ) -> Result<QuickJsValueAdapter, JsError>
pub fn create_typed_array_uint8_copy( &self, buffer: &[u8] ) -> Result<QuickJsValueAdapter, JsError>
pub fn detach_typed_array_buffer( &self, array: &QuickJsValueAdapter ) -> Result<Vec<u8>, JsError>
pub fn copy_typed_array_buffer( &self, array: &QuickJsValueAdapter ) -> Result<Vec<u8>, JsError>
pub fn get_proxy_instance_info(
&self,
obj: &QuickJsValueAdapter
) -> Result<(String, JsProxyInstanceId), JsError>where
Self: Sized,
pub fn to_js_value_facade(
&self,
js_value: &QuickJsValueAdapter
) -> Result<JsValueFacade, JsError>where
Self: Sized + 'static,
sourcepub fn from_js_value_facade(
&self,
value_facade: JsValueFacade
) -> Result<QuickJsValueAdapter, JsError>where
Self: Sized + 'static,
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)
pub fn value_adapter_to_serde_value( &self, value_adapter: &QuickJsValueAdapter ) -> Result<Value, JsError>
pub fn serde_value_to_value_adapter( &self, value: Value ) -> Result<QuickJsValueAdapter, JsError>
sourcepub fn create_resolving_promise_async<P, R: Send + 'static, M>(
&self,
producer: P,
mapper: M
) -> Result<QuickJsValueAdapter, JsError>
pub fn create_resolving_promise_async<P, R: Send + 'static, M>( &self, producer: P, mapper: M ) -> Result<QuickJsValueAdapter, JsError>
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
sourcepub fn create_resolving_promise<P, R: Send + 'static, M>(
&self,
producer: P,
mapper: M
) -> Result<QuickJsValueAdapter, JsError>
pub fn create_resolving_promise<P, R: Send + 'static, M>( &self, producer: P, mapper: M ) -> Result<QuickJsValueAdapter, JsError>
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§
Auto Trait Implementations§
impl !RefUnwindSafe for QuickJsRealmAdapter
impl !Send for QuickJsRealmAdapter
impl !Sync for QuickJsRealmAdapter
impl Unpin for QuickJsRealmAdapter
impl !UnwindSafe for QuickJsRealmAdapter
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<D> OwoColorize for D
impl<D> OwoColorize for D
source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
source§fn black<'a>(&'a self) -> FgColorDisplay<'a, Black, Self>
fn black<'a>(&'a self) -> FgColorDisplay<'a, Black, Self>
source§fn on_black<'a>(&'a self) -> BgColorDisplay<'a, Black, Self>
fn on_black<'a>(&'a self) -> BgColorDisplay<'a, Black, Self>
source§fn red<'a>(&'a self) -> FgColorDisplay<'a, Red, Self>
fn red<'a>(&'a self) -> FgColorDisplay<'a, Red, Self>
source§fn on_red<'a>(&'a self) -> BgColorDisplay<'a, Red, Self>
fn on_red<'a>(&'a self) -> BgColorDisplay<'a, Red, Self>
source§fn green<'a>(&'a self) -> FgColorDisplay<'a, Green, Self>
fn green<'a>(&'a self) -> FgColorDisplay<'a, Green, Self>
source§fn on_green<'a>(&'a self) -> BgColorDisplay<'a, Green, Self>
fn on_green<'a>(&'a self) -> BgColorDisplay<'a, Green, Self>
source§fn yellow<'a>(&'a self) -> FgColorDisplay<'a, Yellow, Self>
fn yellow<'a>(&'a self) -> FgColorDisplay<'a, Yellow, Self>
source§fn on_yellow<'a>(&'a self) -> BgColorDisplay<'a, Yellow, Self>
fn on_yellow<'a>(&'a self) -> BgColorDisplay<'a, Yellow, Self>
source§fn blue<'a>(&'a self) -> FgColorDisplay<'a, Blue, Self>
fn blue<'a>(&'a self) -> FgColorDisplay<'a, Blue, Self>
source§fn on_blue<'a>(&'a self) -> BgColorDisplay<'a, Blue, Self>
fn on_blue<'a>(&'a self) -> BgColorDisplay<'a, Blue, Self>
source§fn magenta<'a>(&'a self) -> FgColorDisplay<'a, Magenta, Self>
fn magenta<'a>(&'a self) -> FgColorDisplay<'a, Magenta, Self>
source§fn on_magenta<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>
fn on_magenta<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>
source§fn purple<'a>(&'a self) -> FgColorDisplay<'a, Magenta, Self>
fn purple<'a>(&'a self) -> FgColorDisplay<'a, Magenta, Self>
source§fn on_purple<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>
fn on_purple<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>
source§fn cyan<'a>(&'a self) -> FgColorDisplay<'a, Cyan, Self>
fn cyan<'a>(&'a self) -> FgColorDisplay<'a, Cyan, Self>
source§fn on_cyan<'a>(&'a self) -> BgColorDisplay<'a, Cyan, Self>
fn on_cyan<'a>(&'a self) -> BgColorDisplay<'a, Cyan, Self>
source§fn white<'a>(&'a self) -> FgColorDisplay<'a, White, Self>
fn white<'a>(&'a self) -> FgColorDisplay<'a, White, Self>
source§fn on_white<'a>(&'a self) -> BgColorDisplay<'a, White, Self>
fn on_white<'a>(&'a self) -> BgColorDisplay<'a, White, Self>
source§fn default_color<'a>(&'a self) -> FgColorDisplay<'a, Default, Self>
fn default_color<'a>(&'a self) -> FgColorDisplay<'a, Default, Self>
source§fn on_default_color<'a>(&'a self) -> BgColorDisplay<'a, Default, Self>
fn on_default_color<'a>(&'a self) -> BgColorDisplay<'a, Default, Self>
source§fn bright_black<'a>(&'a self) -> FgColorDisplay<'a, BrightBlack, Self>
fn bright_black<'a>(&'a self) -> FgColorDisplay<'a, BrightBlack, Self>
source§fn on_bright_black<'a>(&'a self) -> BgColorDisplay<'a, BrightBlack, Self>
fn on_bright_black<'a>(&'a self) -> BgColorDisplay<'a, BrightBlack, Self>
source§fn bright_red<'a>(&'a self) -> FgColorDisplay<'a, BrightRed, Self>
fn bright_red<'a>(&'a self) -> FgColorDisplay<'a, BrightRed, Self>
source§fn on_bright_red<'a>(&'a self) -> BgColorDisplay<'a, BrightRed, Self>
fn on_bright_red<'a>(&'a self) -> BgColorDisplay<'a, BrightRed, Self>
source§fn bright_green<'a>(&'a self) -> FgColorDisplay<'a, BrightGreen, Self>
fn bright_green<'a>(&'a self) -> FgColorDisplay<'a, BrightGreen, Self>
source§fn on_bright_green<'a>(&'a self) -> BgColorDisplay<'a, BrightGreen, Self>
fn on_bright_green<'a>(&'a self) -> BgColorDisplay<'a, BrightGreen, Self>
source§fn bright_yellow<'a>(&'a self) -> FgColorDisplay<'a, BrightYellow, Self>
fn bright_yellow<'a>(&'a self) -> FgColorDisplay<'a, BrightYellow, Self>
source§fn on_bright_yellow<'a>(&'a self) -> BgColorDisplay<'a, BrightYellow, Self>
fn on_bright_yellow<'a>(&'a self) -> BgColorDisplay<'a, BrightYellow, Self>
source§fn bright_blue<'a>(&'a self) -> FgColorDisplay<'a, BrightBlue, Self>
fn bright_blue<'a>(&'a self) -> FgColorDisplay<'a, BrightBlue, Self>
source§fn on_bright_blue<'a>(&'a self) -> BgColorDisplay<'a, BrightBlue, Self>
fn on_bright_blue<'a>(&'a self) -> BgColorDisplay<'a, BrightBlue, Self>
source§fn bright_magenta<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
fn bright_magenta<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
source§fn on_bright_magenta<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
fn on_bright_magenta<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
source§fn bright_purple<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
fn bright_purple<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
source§fn on_bright_purple<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
fn on_bright_purple<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
source§fn bright_cyan<'a>(&'a self) -> FgColorDisplay<'a, BrightCyan, Self>
fn bright_cyan<'a>(&'a self) -> FgColorDisplay<'a, BrightCyan, Self>
source§fn on_bright_cyan<'a>(&'a self) -> BgColorDisplay<'a, BrightCyan, Self>
fn on_bright_cyan<'a>(&'a self) -> BgColorDisplay<'a, BrightCyan, Self>
source§fn bright_white<'a>(&'a self) -> FgColorDisplay<'a, BrightWhite, Self>
fn bright_white<'a>(&'a self) -> FgColorDisplay<'a, BrightWhite, Self>
source§fn on_bright_white<'a>(&'a self) -> BgColorDisplay<'a, BrightWhite, Self>
fn on_bright_white<'a>(&'a self) -> BgColorDisplay<'a, BrightWhite, Self>
source§fn bold<'a>(&'a self) -> BoldDisplay<'a, Self>
fn bold<'a>(&'a self) -> BoldDisplay<'a, Self>
source§fn dimmed<'a>(&'a self) -> DimDisplay<'a, Self>
fn dimmed<'a>(&'a self) -> DimDisplay<'a, Self>
source§fn italic<'a>(&'a self) -> ItalicDisplay<'a, Self>
fn italic<'a>(&'a self) -> ItalicDisplay<'a, Self>
source§fn underline<'a>(&'a self) -> UnderlineDisplay<'a, Self>
fn underline<'a>(&'a self) -> UnderlineDisplay<'a, Self>
source§fn blink<'a>(&'a self) -> BlinkDisplay<'a, Self>
fn blink<'a>(&'a self) -> BlinkDisplay<'a, Self>
source§fn blink_fast<'a>(&'a self) -> BlinkFastDisplay<'a, Self>
fn blink_fast<'a>(&'a self) -> BlinkFastDisplay<'a, Self>
source§fn reversed<'a>(&'a self) -> ReversedDisplay<'a, Self>
fn reversed<'a>(&'a self) -> ReversedDisplay<'a, Self>
source§fn strikethrough<'a>(&'a self) -> StrikeThroughDisplay<'a, Self>
fn strikethrough<'a>(&'a self) -> StrikeThroughDisplay<'a, Self>
source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg
or
a color-specific method, such as OwoColorize::green
, Read moresource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg
or
a color-specific method, such as OwoColorize::on_yellow
, Read more