Trait iffi::Iffi

source ·
pub unsafe trait Iffi<U: Nicheless = MaybeInvalid<Self>> {
    // Required method
    fn can_transmute(superset: &U) -> Result<(), Error>;
}
Expand description

The core trait of the iffi crate.

This is typically implemented by deriving Iffi, which can be done for all FFI-safe structs and enums.

The set of possible values of Self that are well-defined is a subset of the well-defined values of the U type parameter.

The U type parameter, called a universe, must be Nicheless.

Safety

The implementation must guarantee that Self and U have identical layouts - the same size, alignment and ABI.

can_transmute must return not return Ok(()) unless U can safely be transmuted into Self.

Required Methods§

source

fn can_transmute(superset: &U) -> Result<(), Error>

Checks for the safety of transmuting U into Self. Returns Ok(()) if the value is safe, and Err(iffi::Error) otherwise.

Implementations on Foreign Types§

source§

impl Iffi<MaybeInvalid<NonZeroU8>> for NonZeroU8

source§

impl Iffi<i16> for NonZeroI16

source§

impl Iffi<MaybeInvalid<NonZeroIsize>> for NonZeroIsize

source§

impl Iffi<MaybeInvalid<NonZeroU64>> for NonZeroU64

source§

impl Iffi<u64> for NonZeroU64

source§

impl Iffi<MaybeInvalid<NonZeroU16>> for NonZeroU16

source§

impl Iffi<isize> for NonZeroIsize

source§

impl Iffi<i128> for NonZeroI128

source§

impl Iffi<i64> for NonZeroI64

source§

impl Iffi<MaybeInvalid<NonZeroU128>> for NonZeroU128

source§

impl Iffi<i8> for NonZeroI8

source§

fn can_transmute(superset: &i8) -> Result<(), Error>

source§

impl Iffi<MaybeInvalid<NonZeroI16>> for NonZeroI16

source§

impl Iffi<u128> for NonZeroU128

source§

impl Iffi<MaybeInvalid<NonZeroI8>> for NonZeroI8

source§

impl Iffi<u8> for NonZeroU8

source§

fn can_transmute(superset: &u8) -> Result<(), Error>

source§

impl Iffi<u16> for NonZeroU16

source§

impl Iffi<u32> for NonZeroU32

source§

impl Iffi<i32> for NonZeroI32

source§

impl Iffi<MaybeInvalid<NonZeroI32>> for NonZeroI32

source§

impl Iffi<MaybeInvalid<NonZeroI128>> for NonZeroI128

source§

impl Iffi<MaybeInvalid<NonZeroI64>> for NonZeroI64

source§

impl Iffi<usize> for NonZeroUsize

source§

impl Iffi<MaybeInvalid<NonZeroUsize>> for NonZeroUsize

source§

impl Iffi<MaybeInvalid<NonZeroU32>> for NonZeroU32

Implementors§

source§

impl<U: Nicheless> Iffi<MaybeInvalid<U>> for U

source§

impl<U: Nicheless> Iffi<U> for U