[][src]Trait ffi_convert::RawPointerConverter

pub trait RawPointerConverter<T>: Sized {
    fn into_raw_pointer(self) -> *const T;
unsafe fn from_raw_pointer(input: *const T) -> Result<Self, Error>; unsafe fn drop_raw_pointer(input: *const T) -> Result<(), Error> { ... } }

Trait representing the creation of a raw pointer from a struct and the recovery of said pointer.

The from_raw_pointer function should be used only on pointers obtained thought the into_raw_pointer method (and is thus unsafe as we don't have any way to get insurance of that from the compiler).

The from_raw_pointer effectively takes back ownership of the pointer. If you didn't create the pointer yourself, please use the as_ref method on the raw pointer to borrow it

A generic implementation of this trait exist for every struct, it will use a Box to create the pointer. There is also a special implementation available in order to create a *const libc::c_char from a CString.

Required methods

fn into_raw_pointer(self) -> *const T

unsafe fn from_raw_pointer(input: *const T) -> Result<Self, Error>

Loading content...

Provided methods

unsafe fn drop_raw_pointer(input: *const T) -> Result<(), Error>

Loading content...

Implementations on Foreign Types

impl RawPointerConverter<c_void> for CString[src]

impl RawPointerConverter<i8> for CString[src]

Loading content...

Implementors

impl<T> RawPointerConverter<T> for T[src]

TODO custom derive instead of generic impl, this would prevent CString from having 2 impls... Trait representing conversion operations from and to owned type T to a raw pointer to T

Loading content...