pub unsafe trait ForeignType: Sized {
    type CType;
    type Ref: ForeignTypeRef<CType = Self::CType>;
    unsafe fn from_ptr(ptr: *mut Self::CType) -> Self;
fn as_ptr(&self) -> *mut Self::CType; fn into_ptr(self) -> *mut Self::CType { ... } }
Expand description

A type implemented by wrappers over foreign types.


Implementations of ForeignType must guarantee the following:

  • Self::from_ptr(x).as_ptr() == x
  • Self::from_ptr(x).into_ptr(x) == x
  • Self::from_ptr(x).deref().as_ptr(x) == x
  • Self::from_ptr(x).deref_mut().as_ptr(x) == x
  • Self::from_ptr(x).as_ref().as_ptr(x) == x
  • Self::from_ptr(x).as_mut().as_ptr(x) == x

Associated Types

The raw C type.

The type representing a reference to this type.

Required methods

Constructs an instance of this type from its raw type.


ptr must be a valid, owned instance of the native type.

Returns a raw pointer to the wrapped value.

Provided methods

Consumes the wrapper and returns the raw pointer.