Struct JsEngine

Source
pub struct JsEngine { /* private fields */ }

Implementations§

Source§

impl JsEngine

Source

pub fn new() -> Result<Self, JsError>

Source

pub fn with_interop<I: JsInterop>(interop: I) -> Result<Self, JsError>

Source

pub fn version() -> u32

Source

pub fn version_info() -> &'static str

Source

pub fn interop(&self) -> Pin<&dyn JsInterop>

Source

pub fn interop_as<I: JsInterop>(&self) -> Pin<&I>

Source

pub fn interop_mut(&mut self) -> Pin<&mut dyn JsInterop>

Source

pub fn interop_as_mut<I: JsInterop>(&mut self) -> Pin<&mut I>

Source

pub fn ctx(&mut self) -> &mut DukContext

Methods from Deref<Target = DukContext>§

Source

pub fn normalize_index(&self, index: i32) -> i32

Source

pub fn get_top(&self) -> i32

Source

pub fn dup(&self, index: i32)

Source

pub fn remove(&self, index: i32)

Source

pub fn pop(&self)

Source

pub fn pop_n(&self, n: i32)

Source

pub fn swap(&self, idx1: i32, idx2: i32)

Source

pub fn push_this(&self)

Source

pub fn push_thread(&self) -> i32

Source

pub fn push_thread_new_globalenv(&self) -> i32

Source

pub fn push_global_object(&self)

Source

pub fn push_boolean(&self, value: bool)

Source

pub fn push_null(&self)

Source

pub fn push_undefined(&self)

Source

pub fn push_i32(&self, value: i32)

Source

pub fn push_u32(&self, value: u32)

Source

pub fn push_number(&self, value: f64)

Source

pub fn push_string(&self, value: &str)

Source

pub fn push_object(&self) -> i32

Source

pub fn push_ext_buffer(&self, data: &[u8])

Source

pub fn push_array(&self) -> i32

Source

pub fn push_function(&self, func_name: &str, nargs: i32)

Source

pub fn put_prop_function(&self, obj_index: i32, func_name: &str, nargs: i32)

Source

pub fn put_global_function(&self, func_name: &str, nargs: i32)

Source

pub fn get_type(&self, index: i32) -> DukType

Source

pub fn is_string(&self, index: i32) -> bool

Source

pub fn is_number(&self, index: i32) -> bool

Source

pub fn is_object(&self, index: i32) -> bool

Source

pub fn is_array(&self, index: i32) -> bool

Source

pub fn is_pure_object(&self, index: i32) -> bool

Source

pub fn get_string(&self, index: i32) -> &str

Source

pub fn get_buffer(&self, index: i32) -> &[u8]

Source

pub fn get_number(&self, index: i32) -> f64

Source

pub fn get_boolean(&self, index: i32) -> bool

Source

pub fn get_context(&self, index: i32) -> Result<DukContextGuard<'_>, JsError>

Source

pub fn get_prop(&self, obj_index: i32) -> bool

Source

pub fn put_prop(&self, obj_index: i32)

Source

pub fn get_prop_string(&self, obj_index: i32, key: &str) -> bool

Source

pub fn put_prop_string(&self, obj_index: i32, key: &str)

Source

pub fn get_prop_index(&self, obj_index: i32, index: u32) -> bool

Source

pub fn put_prop_index(&self, obj_index: i32, index: u32)

Source

pub fn get_global_string(&self, key: &str) -> bool

Source

pub fn put_global_string(&self, key: &str)

Source

pub fn get_length(&self, obj_index: i32) -> usize

Source

pub fn enum_indices(&self, obj_index: i32)

Source

pub fn enum_keys(&self, obj_index: i32)

Source

pub fn next(&self, obj_index: i32) -> bool

Source

pub fn call_prop(&self, obj_index: i32, nargs: usize)

Source

pub fn pcall(&self, nargs: usize) -> Result<(), i32>

Source

pub fn pcall_method(&self, nargs: usize) -> Result<(), i32>

Source

pub fn pcall_prop(&self, obj_index: i32, nargs: usize) -> Result<(), i32>

Source

pub fn safe_to_lstring(&self, obj_index: i32) -> String

Source

pub fn throw(&self)

Source

pub fn push_context_dump(&self)

Source

pub fn get_stack_dump(&self) -> String

Source

pub fn propagate_js_error<T>( &self, js_res: Result<T, i32>, ) -> Result<T, JsError>

Propagate JS error to Rust, popping the error from the stack. js_res: Result<(), i32> - JS result returned by protected call functions. If it is an error, it will be converted to JsError. This method should be called immediately after a protected call to handle the error.

Source

pub fn eval(&self, code: &str) -> Result<(), JsError>

Source

pub fn eval_file(&self, filename: &str, code: &str) -> Result<(), JsError>

Source

pub fn compile(&self, code: &str) -> Result<(), JsError>

Source

pub fn compile_file(&self, filename: &str, code: &str) -> Result<(), JsError>

Source

pub fn write<O: WriteJs>(&self, obj: &O) -> Result<(), JsError>

Source

pub fn read<O: ReadJs>(&self, obj_index: i32) -> Result<O, JsError>

Source

pub fn read_top<O: ReadJs>(&self) -> Result<O, JsError>

Source

pub fn init_console(&self)

Initialize console functions.

Source

pub fn xcopy_top(&self, from: &DukContext, count: i32)

Source

pub fn xmove_top(&self, from: &mut DukContext, count: i32)

Source

pub fn check_stack(&self, extra: i32) -> Result<(), JsError>

Source

pub fn check_stack_top(&self, top: i32) -> Result<(), JsError>

Source

pub fn set_global_object(&self)

Source

pub fn gc(&self)

Trait Implementations§

Source§

impl Debug for JsEngine

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for JsEngine

Source§

type Target = DukContext

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for JsEngine

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl Drop for JsEngine

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for JsEngine

SAFETY: JsEngine is Send and Sync since it owns Duktape heap. A Duktape heap can only be accessed by one native thread at a time (thread-safety) Rust ownership system ensures that JsEngine is not shared between threads without synchronization.

Source§

impl Sync for JsEngine

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, 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

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

Source§

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>,

Source§

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.