Struct deno_core::ExternalPointer
source · pub struct ExternalPointer<E: Externalizable> { /* private fields */ }
Expand description
A strongly-typed external pointer. As this is a shared pointer, it only provides immutable references to
the underlying data. To allow for interior mutation, use an interior-mutable container such as [RefCell
].
Implementations§
source§impl<E: Externalizable> ExternalPointer<E>
impl<E: Externalizable> ExternalPointer<E>
pub fn new(external: E) -> Self
pub fn into_raw(self) -> *const c_void
sourcepub fn from_raw(ptr: *const c_void) -> Self
pub fn from_raw(ptr: *const c_void) -> Self
Create an ExternalPointer
from a raw pointer. This does not validate the pointer at all.
sourcepub unsafe fn unsafely_deref(&self) -> &E
pub unsafe fn unsafely_deref(&self) -> &E
Unsafely retrieves the underlying object from this pointer after validating it.
§Safety
This method is inherently unsafe because we cannot know if the underlying memory has been deallocated at some point.
The lifetime of the return value is tied to the pointer itself, however you must take care not to use methods that
mutate the underlying pointer such as unsafely_take
while this reference is alive.
sourcepub unsafe fn unsafely_take(self) -> E
pub unsafe fn unsafely_take(self) -> E
Unsafely takes the object from this external.
§Safety
This method is inherently unsafe because we cannot know if the underlying memory has been deallocated at some point.
You must ensure that no other references to this object are alive at the time you call this method.