Skip to main content

Runtime

Struct Runtime 

Source
pub struct Runtime(/* private fields */);
Expand description

A ref counted handle to runtime. When last handle dropped, associated runtime will be dropped.

Implementations§

Source§

impl Runtime

Source

pub fn create() -> Result<Runtime, i32>

create runtime

Methods from Deref<Target = RuntimeImpl>§

Source

pub fn is_class_registered(&self, class_id: ClassID) -> bool

test if class_id exists.

Source

pub fn register_class(&mut self, class_def: &ClassDef) -> Result<ClassID, i32>

register a class defination. returns the assigned class_id.

Source

pub fn create_context_ecma<'a>(&mut self) -> Result<Context<'a>, i32>

Creates new context initialized with ECMA standard classes and global entries.

This also provides a demostration on how to use ContextBuilder to customize a context.

Source

pub fn set_interrupt_handler<F: InterruptFn + 'static>(&mut self, f: F)

Source

pub fn unset_interrupt_handler(&mut self)

Source

pub fn gc_set_threshold(&mut self, threshold: usize)

Source

pub fn gc_info(&self) -> &GcPartition

Source

pub fn gc_alloc<T: GcTracable>( &mut self, data: T, ) -> Result<GcRef<T>, (GcError, T)>

alloc data in gc

Source

pub fn gc_collect(&mut self) -> usize

collect garbage.

Source

pub fn gc_set_trace_handler(&mut self, f: impl Fn(&mut GcTracer) + 'static)

Source

pub fn gc_request(&mut self)

request gc collect

Source

pub fn gc_has_request(&self) -> bool

request gc collect

Source

pub fn set_module_loader( &mut self, norm_func: Option<fn(ctx: Context<'_>, base_name: &str, name: &str, opaque: *mut c_void) -> Result<String, i32>>, load_func: fn(ctx: Context<'_>, module_name: &str, opaque: *mut c_void) -> Result<ModuleDef, i32>, opaque: *mut c_void, )

set module loader callbacks

Source

pub fn id(&self) -> usize

Source

pub fn set_stack_size(&mut self, stack_size: usize)

set max stack size. 0 for unlimited

Source

pub fn exception(&self) -> JSValue

get current exception value

Source

pub fn take_exception(&mut self) -> JSValue

get current exception value, then reset current_exception to null.

Source

pub fn stop(&mut self, code: i32)

Source

pub fn tick(&mut self) -> Result<TickStatus, i32>

Trait Implementations§

Source§

impl Clone for Runtime

Source§

fn clone(&self) -> Runtime

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Runtime

Source§

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

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

impl Deref for Runtime

Source§

type Target = RuntimeImpl

The resulting type after dereferencing.
Source§

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

Dereferences the value.
Source§

impl DerefMut for Runtime

Source§

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

Mutably dereferences the value.
Source§

impl Drop for Runtime

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl PartialEq for Runtime

Source§

fn eq(&self, other: &Runtime) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Runtime

Auto Trait Implementations§

§

impl Freeze for Runtime

§

impl !RefUnwindSafe for Runtime

§

impl !Send for Runtime

§

impl !Sync for Runtime

§

impl Unpin for Runtime

§

impl !UnwindSafe for Runtime

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.