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§
sourcefn can_transmute(superset: &U) -> Result<(), Error>
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.