Skip to main content

rquickjs_core/
runtime.rs

1//! QuickJS runtime related types.
2
3mod base;
4mod exotic;
5pub(crate) mod job_error;
6pub(crate) mod opaque;
7pub(crate) mod raw;
8mod userdata;
9
10#[cfg(feature = "futures")]
11mod r#async;
12#[cfg(feature = "futures")]
13pub(crate) mod schedular;
14#[cfg(feature = "futures")]
15mod spawner;
16#[cfg(feature = "futures")]
17pub use spawner::DriveFuture;
18
19use alloc::boxed::Box;
20pub use base::{Runtime, WeakRuntime};
21pub use job_error::JobError;
22pub use userdata::{UserDataError, UserDataGuard};
23
24#[cfg(feature = "futures")]
25pub(crate) use r#async::InnerRuntime;
26#[cfg(feature = "futures")]
27pub use r#async::{AsyncRuntime, AsyncWeakRuntime};
28
29use crate::value::promise::PromiseHookType;
30use crate::{Ctx, Value};
31
32/// The type of the promise hook.
33#[cfg(not(feature = "parallel"))]
34pub type PromiseHook =
35    Box<dyn for<'a> Fn(Ctx<'a>, PromiseHookType, Value<'a>, Value<'a>) + 'static>;
36/// The type of the promise hook.
37#[cfg(feature = "parallel")]
38pub type PromiseHook =
39    Box<dyn for<'a> Fn(Ctx<'a>, PromiseHookType, Value<'a>, Value<'a>) + Send + 'static>;
40
41/// The type of the promise rejection tracker.
42#[cfg(not(feature = "parallel"))]
43pub type RejectionTracker = Box<dyn for<'a> Fn(Ctx<'a>, Value<'a>, Value<'a>, bool) + 'static>;
44/// The type of the promise rejection tracker.
45#[cfg(feature = "parallel")]
46pub type RejectionTracker =
47    Box<dyn for<'a> Fn(Ctx<'a>, Value<'a>, Value<'a>, bool) + Send + 'static>;
48
49/// The type of the interrupt handler.
50#[cfg(not(feature = "parallel"))]
51pub type InterruptHandler = Box<dyn FnMut() -> bool + 'static>;
52/// The type of the interrupt handler.
53#[cfg(feature = "parallel")]
54pub type InterruptHandler = Box<dyn FnMut() -> bool + Send + 'static>;
55
56/// A struct with information about the runtimes memory usage.
57pub type MemoryUsage = crate::qjs::JSMemoryUsage;