Trait iffi::Nicheless

source ·
pub unsafe trait Nicheless: Sized { }
Expand description

Indicates that a value of this type is FFI-safe and well-defined no matter the underlying bit-pattern.

Equally, that the type has no niches.

If you are familiar with bytemuck, types that can implement this trait are a strict superset of types that can implement bytemuck::Pod and a strict subset of types that can implement bytemuck::Zeroable. Namely, Nicheless types:

  • must be FFI-safe (#[repr(C)], #[repr(Int)], or #[repr(transparent)] over an FFI-safe type).
  • must be valid for any bit-pattern, not just all zeros.
  • are allowed to have padding bytes.
  • are allowed to contain pointers, atomics and interior-mutable types.

In the case of niche optimization (where sizeof::<T>() == sizeof::<Option<T>>), the type Option<T> will implement Nicheless if the trait OneNiche is implemented for T.

Iffi is implemented automatically for all types that implement Nicheless, both reflexively and over MaybeInvalid<Self>.

Safety

  • All fields must be nicheless.
  • The type must not be uninhabited.
  • The type must not have pointer metadata.
  • The type must be FFI-safe.

Implementations on Foreign Types§

source§

impl Nicheless for AtomicU8

source§

impl Nicheless for f64

source§

impl Nicheless for AtomicU64

source§

impl Nicheless for i32

source§

impl Nicheless for AtomicUsize

source§

impl Nicheless for AtomicIsize

source§

impl Nicheless for f32

source§

impl Nicheless for AtomicU16

source§

impl Nicheless for u32

source§

impl<T: Nicheless, const N: usize> Nicheless for [T; N]

source§

impl<T: OneNiche> Nicheless for Option<T>

source§

impl Nicheless for isize

source§

impl<T> Nicheless for *const T

source§

impl<T> Nicheless for MaybeUninit<T>

source§

impl Nicheless for i8

source§

impl<T> Nicheless for *mut T

source§

impl<T> Nicheless for PhantomData<T>

source§

impl Nicheless for i128

source§

impl Nicheless for u8

source§

impl Nicheless for i16

source§

impl Nicheless for PhantomPinned

source§

impl Nicheless for AtomicI64

source§

impl Nicheless for AtomicI32

source§

impl Nicheless for u16

source§

impl<T: OneNiche> Nicheless for Result<T, ()>

source§

impl<T> Nicheless for AtomicPtr<T>

source§

impl Nicheless for usize

source§

impl<T: Nicheless> Nicheless for Wrapping<T>

source§

impl<E: OneNiche> Nicheless for Result<(), E>

source§

impl Nicheless for i64

source§

impl Nicheless for u64

source§

impl Nicheless for AtomicU32

source§

impl Nicheless for u128

source§

impl Nicheless for AtomicI16

source§

impl Nicheless for AtomicI8

Implementors§