Trait libffi::high::types::CType

source ·
pub unsafe trait CType: Copy {
    type RetType: From<Self> + TryInto<Self>;

    // Required method
    fn reify() -> Type<Self>;
}
Expand description

Types that we can automatically marshall to/from C.

In particular, for any type T that implements CType, we can get a Type<T> for describing that type. This trait is unsafe to implement because if the libffi type associated with a Rust type doesn’t match then we get undefined behavior.

Required Associated Types§

source

type RetType: From<Self> + TryInto<Self>

The low-level libffi library implicitly extends small integer return values to ffi_arg or ffi_sarg. Track the possibly extended variant of T as an associated type here.

Required Methods§

source

fn reify() -> Type<Self>

Creates or retrieves a Type<T> for any type T: CType.

We can use the resulting object to assemble a CIF to set up a call that uses type T.

Implementations on Foreign Types§

source§

impl<T> CType for *mut T

source§

fn reify() -> Type<Self>

§

type RetType = *mut T

source§

impl CType for u32

source§

fn reify() -> Type<Self>

§

type RetType = u64

source§

impl CType for f64

source§

fn reify() -> Type<Self>

§

type RetType = f64

source§

impl CType for u64

source§

fn reify() -> Type<Self>

§

type RetType = u64

source§

impl CType for i8

source§

fn reify() -> Type<Self>

§

type RetType = i64

source§

impl CType for u16

source§

fn reify() -> Type<Self>

§

type RetType = u64

source§

impl CType for isize

source§

fn reify() -> Type<Self>

§

type RetType = isize

source§

impl CType for i32

source§

fn reify() -> Type<Self>

§

type RetType = i64

source§

impl CType for i64

source§

fn reify() -> Type<Self>

§

type RetType = i64

source§

impl CType for ()

source§

fn reify() -> Type<Self>

§

type RetType = ()

source§

impl<T> CType for *const T

source§

fn reify() -> Type<Self>

§

type RetType = *const T

source§

impl CType for i16

source§

fn reify() -> Type<Self>

§

type RetType = i64

source§

impl CType for usize

source§

fn reify() -> Type<Self>

§

type RetType = usize

source§

impl CType for f32

source§

fn reify() -> Type<Self>

§

type RetType = f32

source§

impl CType for u8

source§

fn reify() -> Type<Self>

§

type RetType = u64

Implementors§