enum Realm<'a> {
AutoRealm(AutoRealm<'a>),
CurrentRealm(&'a mut CurrentRealm<'a>),
}Expand description
Helper type to keep AutoRealm and &mut CurrentRealm alive with Deref to JSContext
Variants§
AutoRealm(AutoRealm<'a>)
CurrentRealm(&'a mut CurrentRealm<'a>)
Methods from Deref<Target = JSContext>§
Sourcepub unsafe fn raw_cx(&mut self) -> *mut JSContext
pub unsafe fn raw_cx(&mut self) -> *mut JSContext
Obtain RawJSContext mutable pointer.
§Safety
No NoGC tokens should be constructed while returned pointer is available to user. In practices this means that one should use the result as direct argument to SpiderMonkey function and not store it in variable.
use mozjs::context::*;
use mozjs::jsapi::JSContext as RawJSContext;
fn SM_function_that_can_trigger_gc(_cx: *mut RawJSContext) {}
fn can_trigger_gc(cx: &mut JSContext) {
unsafe { SM_function_that_can_trigger_gc(cx.raw_cx()) } // returned pointer is immediately used
cx.no_gc(); // this is ok because no outstanding raw pointer is alive
}Sourcepub unsafe fn raw_cx_no_gc(&self) -> *mut JSContext
pub unsafe fn raw_cx_no_gc(&self) -> *mut JSContext
Obtain RawJSContext mutable pointer, that will not be used for GC.
§Safety
No &mut calls should be done on JSContext while returned pointer is available. In practices this means that one should use the result as direct argument to SpiderMonkey function and not store it in variable.
use mozjs::context::*;
use mozjs::jsapi::JSContext as RawJSContext;
fn SM_function_that_cannot_trigger_gc(_cx: *mut RawJSContext) {}
fn f(cx: &mut JSContext) {
unsafe { SM_function_that_cannot_trigger_gc(cx.raw_cx_no_gc()) } // returned pointer is immediately used
}Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Realm<'a>
impl<'a> RefUnwindSafe for Realm<'a>
impl<'a> !Send for Realm<'a>
impl<'a> !Sync for Realm<'a>
impl<'a> Unpin for Realm<'a>
impl<'a> UnsafeUnpin for Realm<'a>
impl<'a> !UnwindSafe for Realm<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Filterable for T
impl<T> Filterable for T
Source§fn filterable(
self,
filter_name: &'static str,
) -> RequestFilterDataProvider<T, fn(DataRequest<'_>) -> bool>
fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(DataRequest<'_>) -> bool>
Creates a filterable data provider with the given name for debugging. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> MaybeBoxed<Box<T>> for T
impl<T> MaybeBoxed<Box<T>> for T
Source§fn maybe_boxed(self) -> Box<T>
fn maybe_boxed(self) -> Box<T>
Convert
Source§impl<T> MaybeBoxed<T> for T
impl<T> MaybeBoxed<T> for T
Source§fn maybe_boxed(self) -> T
fn maybe_boxed(self) -> T
Convert