pub trait PointerWrapper {
    type Borrowed<'a>;

    fn into_pointer(self) -> *const c_void;
    unsafe fn borrow<'a>(ptr: *const c_void) -> Self::Borrowed<'a>;
    unsafe fn from_pointer(ptr: *const c_void) -> Self;

    unsafe fn borrow_mut<T: PointerWrapper>(
        ptr: *const c_void
    ) -> ScopeGuard<T, fn(_: T)> { ... } }
Expand description

Used to convert an object into a raw pointer that represents it.

It can eventually be converted back into the object. This is used to store objects as pointers in kernel data structures, for example, an implementation of Operations in struct file::private_data.

Required Associated Types

Type of values borrowed between calls to PointerWrapper::into_pointer and PointerWrapper::from_pointer.

Required Methods

Returns the raw pointer.

Returns a borrowed value.

Safety

ptr must have been returned by a previous call to PointerWrapper::into_pointer. Additionally, PointerWrapper::from_pointer can only be called after all values returned by PointerWrapper::borrow have been dropped.

Returns the instance back from the raw pointer.

Safety

The passed pointer must come from a previous call to PointerWrapper::into_pointer().

Provided Methods

Returns a mutably borrowed value.

Safety

The passed pointer must come from a previous to PointerWrapper::into_pointer, and no other concurrent users of the pointer (except the ones derived from the returned value) run at least until the returned ScopeGuard is dropped.

Implementations on Foreign Types

Implementors