PtrWrapper

Trait PtrWrapper 

Source
pub trait PtrWrapper: Sized {
    type Pointer;

    // Required methods
    unsafe fn from_raw(raw: *mut Self::Pointer) -> Self;
    fn as_ptr(&self) -> *const Self::Pointer;

    // Provided methods
    fn into_raw(self) -> *mut Self::Pointer { ... }
    fn as_ptr_mut(&mut self) -> *mut Self::Pointer { ... }
}

Required Associated Types§

Required Methods§

Source

unsafe fn from_raw(raw: *mut Self::Pointer) -> Self

Wraps the pointer into a owned wrapper.

§Safety

Pointer must be valid.

Source

fn as_ptr(&self) -> *const Self::Pointer

Returns the inner pointer.

Provided Methods§

Source

fn into_raw(self) -> *mut Self::Pointer

Consumes the wrapper and transfers ownershop to the pointer

This does NOT drop the wrapper internally.

Source

fn as_ptr_mut(&mut self) -> *mut Self::Pointer

Returns the inner pointer (mutable version).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§