Struct rquickjs_core::Context
source · [−]pub struct Context { /* private fields */ }
Expand description
A single execution context with its own global variables and stack.
Can share objects with other contexts of the same runtime.
Implementations
sourceimpl Context
impl Context
pub fn from_ctx<'js>(ctx: Ctx<'js>) -> Result<Self>
sourcepub fn base(runtime: &Runtime) -> Result<Self>
pub fn base(runtime: &Runtime) -> Result<Self>
Creates a base context with only the required functions registered.
If additional functions are required use Context::custom
,
Context::builder
or Context::full
.
sourcepub fn custom<I: Intrinsic>(runtime: &Runtime) -> Result<Self>
pub fn custom<I: Intrinsic>(runtime: &Runtime) -> Result<Self>
Creates a context with only the required intrinsics registered.
If additional functions are required use Context::custom
,
Context::builder
or Context::full
.
sourcepub fn full(runtime: &Runtime) -> Result<Self>
pub fn full(runtime: &Runtime) -> Result<Self>
Creates a context with all standart available intrinsics registered.
If precise controll is required of which functions are available use
Context::custom
or Context::builder
.
sourcepub fn builder() -> ContextBuilder<()>
pub fn builder() -> ContextBuilder<()>
Create a context builder for creating a context with a specific set of intrinsics
pub fn enable_big_num_ext(&self, enable: bool)
sourcepub fn with<F, R>(&self, f: F) -> R where
F: FnOnce(Ctx<'_>) -> R,
pub fn with<F, R>(&self, f: F) -> R where
F: FnOnce(Ctx<'_>) -> R,
A entry point for manipulating and using javascript objects and scripts. The api is structured this way to avoid repeated locking the runtime when ever any function is called. This way the runtime is locked once before executing the callback. Furthermore, this way it is impossible to use values from different runtimes in this context which would otherwise be undefined behaviour.
This is the only way to get a Ctx
object.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Context
impl !Send for Context
impl !Sync for Context
impl Unpin for Context
impl !UnwindSafe for Context
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more