FFIConversion

Trait FFIConversion 

Source
pub trait FFIConversion<T> {
    // Required methods
    unsafe fn ffi_from_const(ffi: *const Self) -> T;
    unsafe fn ffi_to_const(obj: T) -> *const Self;

    // Provided methods
    unsafe fn ffi_from(ffi: *mut Self) -> T { ... }
    unsafe fn ffi_to(obj: T) -> *mut Self { ... }
    unsafe fn ffi_from_opt(ffi: *mut Self) -> Option<T> { ... }
    unsafe fn ffi_to_opt(obj: Option<T>) -> *mut Self
       where Self: Sized { ... }
    unsafe fn destroy(ffi: *mut Self) { ... }
}

Required Methods§

Source

unsafe fn ffi_from_const(ffi: *const Self) -> T

§Safety
Source

unsafe fn ffi_to_const(obj: T) -> *const Self

§Safety

Provided Methods§

Source

unsafe fn ffi_from(ffi: *mut Self) -> T

§Safety
Source

unsafe fn ffi_to(obj: T) -> *mut Self

§Safety
Source

unsafe fn ffi_from_opt(ffi: *mut Self) -> Option<T>

§Safety
Source

unsafe fn ffi_to_opt(obj: Option<T>) -> *mut Self
where Self: Sized,

§Safety
Source

unsafe fn destroy(ffi: *mut Self)

§Safety

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.

Implementations on Foreign Types§

Source§

impl FFIConversion<&str> for c_char

Source§

unsafe fn ffi_from_const(ffi: *const Self) -> &'static str

Source§

unsafe fn ffi_to_const(obj: &str) -> *const Self

Source§

unsafe fn ffi_from(ffi: *mut Self) -> &'static str

Source§

unsafe fn ffi_to(obj: &str) -> *mut Self

Source§

unsafe fn destroy(ffi: *mut Self)

Source§

impl FFIConversion<String> for c_char

Source§

unsafe fn ffi_from_const(ffi: *const Self) -> String

Source§

unsafe fn ffi_to_const(obj: String) -> *const Self

Source§

unsafe fn ffi_from(ffi: *mut Self) -> String

Source§

unsafe fn ffi_to(obj: String) -> *mut Self

Source§

unsafe fn destroy(ffi: *mut Self)

Implementors§