pub struct Handle<'a, 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<JSVal, TempAllocPolicy>>
impl<'a> Handle<'a, StackGCVector<JSVal, TempAllocPolicy>>
Source§impl<'a> Handle<'a, StackGCVector<*mut JSString, TempAllocPolicy>>
impl<'a> Handle<'a, StackGCVector<*mut JSString, TempAllocPolicy>>
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: 'r, 'cx: 'r, 'r>(&'s self, _no_gc: &'cx NoGC) -> &'r Twhere
'a: 's,
pub fn as_ref<'s: 'r, 'cx: 'r, 'r>(&'s self, _no_gc: &'cx NoGC) -> &'r Twhere
'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) -> Self
pub unsafe fn from_raw(handle: RawHandle<T>) -> Self
Trait Implementations§
Source§impl<'a, T> IntoHandle for Handle<'a, T>
impl<'a, T> IntoHandle for Handle<'a, T>
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