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

Fields§

§id: String§context: *mut JSContext

Implementations§

source§

impl QuickJsRealmAdapter

source

pub fn print_stats(&self)

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) -> R
where C: FnOnce(QuickJsValueAdapter) -> R,

source

pub unsafe fn with_context<C, R>(context: *mut JSContext, consumer: C) -> R
where 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>

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>

source

pub fn traverse_array_mut<F>( &self, array: &QuickJsValueAdapter, visitor: F, ) -> 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) -> R
where 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 T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where 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> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where 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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<D> OwoColorize for D

source§

fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>
where C: Color,

Set the foreground color generically Read more
source§

fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>
where C: Color,

Set the background color generically. Read more
source§

fn black<'a>(&'a self) -> FgColorDisplay<'a, Black, Self>

Change the foreground color to black
source§

fn on_black<'a>(&'a self) -> BgColorDisplay<'a, Black, Self>

Change the background color to black
source§

fn red<'a>(&'a self) -> FgColorDisplay<'a, Red, Self>

Change the foreground color to red
source§

fn on_red<'a>(&'a self) -> BgColorDisplay<'a, Red, Self>

Change the background color to red
source§

fn green<'a>(&'a self) -> FgColorDisplay<'a, Green, Self>

Change the foreground color to green
source§

fn on_green<'a>(&'a self) -> BgColorDisplay<'a, Green, Self>

Change the background color to green
source§

fn yellow<'a>(&'a self) -> FgColorDisplay<'a, Yellow, Self>

Change the foreground color to yellow
source§

fn on_yellow<'a>(&'a self) -> BgColorDisplay<'a, Yellow, Self>

Change the background color to yellow
source§

fn blue<'a>(&'a self) -> FgColorDisplay<'a, Blue, Self>

Change the foreground color to blue
source§

fn on_blue<'a>(&'a self) -> BgColorDisplay<'a, Blue, Self>

Change the background color to blue
source§

fn magenta<'a>(&'a self) -> FgColorDisplay<'a, Magenta, Self>

Change the foreground color to magenta
source§

fn on_magenta<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>

Change the background color to magenta
source§

fn purple<'a>(&'a self) -> FgColorDisplay<'a, Magenta, Self>

Change the foreground color to purple
source§

fn on_purple<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>

Change the background color to purple
source§

fn cyan<'a>(&'a self) -> FgColorDisplay<'a, Cyan, Self>

Change the foreground color to cyan
source§

fn on_cyan<'a>(&'a self) -> BgColorDisplay<'a, Cyan, Self>

Change the background color to cyan
source§

fn white<'a>(&'a self) -> FgColorDisplay<'a, White, Self>

Change the foreground color to white
source§

fn on_white<'a>(&'a self) -> BgColorDisplay<'a, White, Self>

Change the background color to white
source§

fn default_color<'a>(&'a self) -> FgColorDisplay<'a, Default, Self>

Change the foreground color to the terminal default
source§

fn on_default_color<'a>(&'a self) -> BgColorDisplay<'a, Default, Self>

Change the background color to the terminal default
source§

fn bright_black<'a>(&'a self) -> FgColorDisplay<'a, BrightBlack, Self>

Change the foreground color to bright black
source§

fn on_bright_black<'a>(&'a self) -> BgColorDisplay<'a, BrightBlack, Self>

Change the background color to bright black
source§

fn bright_red<'a>(&'a self) -> FgColorDisplay<'a, BrightRed, Self>

Change the foreground color to bright red
source§

fn on_bright_red<'a>(&'a self) -> BgColorDisplay<'a, BrightRed, Self>

Change the background color to bright red
source§

fn bright_green<'a>(&'a self) -> FgColorDisplay<'a, BrightGreen, Self>

Change the foreground color to bright green
source§

fn on_bright_green<'a>(&'a self) -> BgColorDisplay<'a, BrightGreen, Self>

Change the background color to bright green
source§

fn bright_yellow<'a>(&'a self) -> FgColorDisplay<'a, BrightYellow, Self>

Change the foreground color to bright yellow
source§

fn on_bright_yellow<'a>(&'a self) -> BgColorDisplay<'a, BrightYellow, Self>

Change the background color to bright yellow
source§

fn bright_blue<'a>(&'a self) -> FgColorDisplay<'a, BrightBlue, Self>

Change the foreground color to bright blue
source§

fn on_bright_blue<'a>(&'a self) -> BgColorDisplay<'a, BrightBlue, Self>

Change the background color to bright blue
source§

fn bright_magenta<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>

Change the foreground color to bright magenta
source§

fn on_bright_magenta<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>

Change the background color to bright magenta
source§

fn bright_purple<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>

Change the foreground color to bright purple
source§

fn on_bright_purple<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>

Change the background color to bright purple
source§

fn bright_cyan<'a>(&'a self) -> FgColorDisplay<'a, BrightCyan, Self>

Change the foreground color to bright cyan
source§

fn on_bright_cyan<'a>(&'a self) -> BgColorDisplay<'a, BrightCyan, Self>

Change the background color to bright cyan
source§

fn bright_white<'a>(&'a self) -> FgColorDisplay<'a, BrightWhite, Self>

Change the foreground color to bright white
source§

fn on_bright_white<'a>(&'a self) -> BgColorDisplay<'a, BrightWhite, Self>

Change the background color to bright white
source§

fn bold<'a>(&'a self) -> BoldDisplay<'a, Self>

Make the text bold
source§

fn dimmed<'a>(&'a self) -> DimDisplay<'a, Self>

Make the text dim
source§

fn italic<'a>(&'a self) -> ItalicDisplay<'a, Self>

Make the text italicized
source§

fn underline<'a>(&'a self) -> UnderlineDisplay<'a, Self>

Make the text italicized
Make the text blink
Make the text blink (but fast!)
source§

fn reversed<'a>(&'a self) -> ReversedDisplay<'a, Self>

Swap the foreground and background colors
source§

fn hidden<'a>(&'a self) -> HiddenDisplay<'a, Self>

Hide the text
source§

fn strikethrough<'a>(&'a self) -> StrikeThroughDisplay<'a, Self>

Cross out the text
source§

fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the foreground color at runtime. Only use if you do not know which color will be used at compile-time. If the color is constant, use either OwoColorize::fg or a color-specific method, such as OwoColorize::green, Read more
source§

fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the background color at runtime. Only use if you do not know what color to use at compile-time. If the color is constant, use either OwoColorize::bg or a color-specific method, such as OwoColorize::on_yellow, Read more
source§

fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the foreground color to a specific RGB value.
source§

fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the background color to a specific RGB value.
source§

fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>

Sets the foreground color to an RGB value.
source§

fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>

Sets the background color to an RGB value.
source§

fn style(&self, style: Style) -> Styled<&Self>

Apply a runtime-determined style
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where 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 T
where 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.
source§

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

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more