pub(crate) struct Handle<'a, T>where
T: 'a,{
pub(crate) ptr: NonNull<T>,
pub(crate) _phantom: PhantomData<&'a T>,
}Fields§
§ptr: NonNull<T>§_phantom: PhantomData<&'a T>Implementations§
Source§impl<'a> Handle<'a, StackGCVector<Value>>
impl<'a> Handle<'a, StackGCVector<Value>>
Source§impl<'a, T> Handle<'a, T>
impl<'a, T> Handle<'a, T>
pub fn get(&self) -> Twhere
T: Copy,
Sourcepub fn as_ref<'s, 'cx, 'r>(&'s self, _no_gc: &'cx NoGC) -> &'r Twhere
's: 'r,
'cx: 'r,
'a: 's,
pub fn as_ref<'s, 'cx, 'r>(&'s self, _no_gc: &'cx NoGC) -> &'r Twhere
's: 'r,
'cx: 'r,
'a: 's,
Obtains a reference to the value pointed to by this handle.
While this reference is alive, no GC can occur, because of the _no_gc argument:
ⓘ
use mozjs::context::*;
use mozjs::jsapi::JSObject;
use mozjs::rooted;
fn gc(cx: &mut JSContext) {}
fn f(cx: &mut JSContext, obj: *mut JSObject) {
rooted!(&in(cx) let mut root = obj);
let handle = root.handle();
let r = handle.as_ref(cx);
gc(cx); // cannot call gc while r (thus cx borrow) is alive
drop(r); // otherwise rust automatically drops r before gc call
}pub unsafe fn from_marked_location(ptr: *const T) -> Handle<'a, T>
pub unsafe fn from_raw(handle: Handle<T>) -> Handle<'a, T>
Trait Implementations§
Source§impl<'a, T> IntoHandle for Handle<'a, T>
impl<'a, T> IntoHandle for Handle<'a, T>
Source§impl<'a> ToJSValConvertible for Handle<'a, Value>
impl<'a> ToJSValConvertible for Handle<'a, Value>
Source§unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandle<'_, Value>)
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandle<'_, Value>)
Convert
self to a JSVal. JSAPI failure causes a panic.Source§fn safe_to_jsval(&self, cx: &mut JSContext, rval: MutableHandle<'_, Value>)
fn safe_to_jsval(&self, cx: &mut JSContext, rval: MutableHandle<'_, Value>)
Convert
self to a JSVal. JSAPI failure causes a panic.impl<T> Copy for Handle<'_, T>
Auto Trait Implementations§
impl<'a, T> Freeze for Handle<'a, T>
impl<'a, T> RefUnwindSafe for Handle<'a, T>where
T: RefUnwindSafe,
impl<'a, T> !Send for Handle<'a, T>
impl<'a, T> !Sync for Handle<'a, T>
impl<'a, T> Unpin for Handle<'a, T>
impl<'a, T> UnwindSafe for Handle<'a, T>where
T: RefUnwindSafe,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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