Skip to main content

StableLayout

Trait StableLayout 

Source
pub unsafe trait StableLayout { }
Expand description

Indicates a type with a layout that is stable across Rust compiler versions.

§Safety

The type’s Type Layout must fit one of the following:

  • Primitive layout types of 64-bits or less.
    • Examples: i8, u32
  • Any zero-sized type (ZST).
    • Examples: ()
  • repr(C) struct or union types when all fields are also StableLayout.
    • Examples: Most libc and winapi types.
  • repr(transparent) struct or union types when the non-ZST field is also StableLayout.
  • Any other layout that is guaranteed by Rust.
    • Examples: &T and &mut T where T: Sized.

Specifically there are some things that this type does not attempt to guarantee. StableLayout types can have:

  • Uninitialized bytes, such as padding bytes.
  • Invalid bit patterns, such as bool and char.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl StableLayout for ()

Source§

impl StableLayout for NonZeroI8

Source§

impl StableLayout for NonZeroI16

Source§

impl StableLayout for NonZeroI32

Source§

impl StableLayout for NonZeroI64

Source§

impl StableLayout for NonZeroIsize

Source§

impl StableLayout for NonZeroU8

Source§

impl StableLayout for NonZeroU16

Source§

impl StableLayout for NonZeroU32

Source§

impl StableLayout for NonZeroU64

Source§

impl StableLayout for NonZeroUsize

Source§

impl StableLayout for Option<NonZeroI8>

Source§

impl StableLayout for Option<NonZeroI16>

Source§

impl StableLayout for Option<NonZeroI32>

Source§

impl StableLayout for Option<NonZeroI64>

Source§

impl StableLayout for Option<NonZeroIsize>

Source§

impl StableLayout for Option<NonZeroU8>

Source§

impl StableLayout for Option<NonZeroU16>

Source§

impl StableLayout for Option<NonZeroU32>

Source§

impl StableLayout for Option<NonZeroU64>

Source§

impl StableLayout for Option<NonZeroUsize>

Source§

impl StableLayout for __m128

Available on x86-64 only.
Source§

impl StableLayout for __m256

Available on x86-64 only.
Source§

impl StableLayout for __m128d

Available on x86-64 only.
Source§

impl StableLayout for __m128i

Available on x86-64 only.
Source§

impl StableLayout for __m256d

Available on x86-64 only.
Source§

impl StableLayout for __m256i

Available on x86-64 only.
Source§

impl StableLayout for bool

Source§

impl StableLayout for char

Source§

impl StableLayout for f32

Source§

impl StableLayout for f64

Source§

impl StableLayout for i8

Source§

impl StableLayout for i16

Source§

impl StableLayout for i32

Source§

impl StableLayout for i64

Source§

impl StableLayout for isize

Source§

impl StableLayout for u8

Source§

impl StableLayout for u16

Source§

impl StableLayout for u32

Source§

impl StableLayout for u64

Source§

impl StableLayout for usize

Source§

impl<T> StableLayout for &T
where T: Sized + StableLayout,

Source§

impl<T> StableLayout for &mut T
where T: Sized + StableLayout,

Source§

impl<T> StableLayout for *const T
where T: Sized + StableLayout,

Source§

impl<T> StableLayout for *mut T
where T: Sized + StableLayout,

Source§

impl<T> StableLayout for Box<T>
where T: Sized + StableLayout,

Available on crate feature unsafe_alloc only.
Source§

impl<T> StableLayout for Cell<T>
where T: StableLayout,

Source§

impl<T> StableLayout for ManuallyDrop<T>
where T: StableLayout,

Source§

impl<T> StableLayout for NonNull<T>
where T: Sized + StableLayout,

Source§

impl<T> StableLayout for Option<&T>
where T: Sized + StableLayout,

Source§

impl<T> StableLayout for Option<&mut T>
where T: Sized + StableLayout,

Source§

impl<T> StableLayout for Option<Box<T>>
where T: Sized + StableLayout,

Available on crate feature unsafe_alloc only.
Source§

impl<T> StableLayout for Option<NonNull<T>>
where T: Sized + StableLayout,

Source§

impl<T> StableLayout for PhantomData<T>
where T: StableLayout,

PhantomData is a zero-sized type and so technically it could be defined as always being StableLayout. However, since PhantomData is semantically supposed to indicate to the world that you want to be treated like you’re holding some sort of T, then we will also require that the T be a StableLayout type.

Source§

impl<T> StableLayout for UnsafeCell<T>
where T: StableLayout,

Source§

impl<T> StableLayout for Wrapping<T>
where T: StableLayout,

Source§

impl<T> StableLayout for [T; 0]
where T: StableLayout,

Source§

impl<T> StableLayout for [T; 1]
where T: StableLayout,

Source§

impl<T> StableLayout for [T; 2]
where T: StableLayout,

Source§

impl<T> StableLayout for [T; 3]
where T: StableLayout,

Source§

impl<T> StableLayout for [T; 4]
where T: StableLayout,

Source§

impl<T> StableLayout for [T; 5]
where T: StableLayout,

Source§

impl<T> StableLayout for [T; 6]
where T: StableLayout,

Source§

impl<T> StableLayout for [T; 7]
where T: StableLayout,

Source§

impl<T> StableLayout for [T; 8]
where T: StableLayout,

Source§

impl<T> StableLayout for [T; 9]
where T: StableLayout,

Source§

impl<T> StableLayout for [T; 10]
where T: StableLayout,

Source§

impl<T> StableLayout for [T; 11]
where T: StableLayout,

Source§

impl<T> StableLayout for [T; 12]
where T: StableLayout,

Source§

impl<T> StableLayout for [T; 13]
where T: StableLayout,

Source§

impl<T> StableLayout for [T; 14]
where T: StableLayout,

Source§

impl<T> StableLayout for [T; 15]
where T: StableLayout,

Source§

impl<T> StableLayout for [T; 16]
where T: StableLayout,

Source§

impl<T> StableLayout for [T; 17]
where T: StableLayout,

Source§

impl<T> StableLayout for [T; 18]
where T: StableLayout,

Source§

impl<T> StableLayout for [T; 19]
where T: StableLayout,

Source§

impl<T> StableLayout for [T; 20]
where T: StableLayout,

Source§

impl<T> StableLayout for [T; 21]
where T: StableLayout,

Source§

impl<T> StableLayout for [T; 22]
where T: StableLayout,

Source§

impl<T> StableLayout for [T; 23]
where T: StableLayout,

Source§

impl<T> StableLayout for [T; 24]
where T: StableLayout,

Source§

impl<T> StableLayout for [T; 25]
where T: StableLayout,

Source§

impl<T> StableLayout for [T; 26]
where T: StableLayout,

Source§

impl<T> StableLayout for [T; 27]
where T: StableLayout,

Source§

impl<T> StableLayout for [T; 28]
where T: StableLayout,

Source§

impl<T> StableLayout for [T; 29]
where T: StableLayout,

Source§

impl<T> StableLayout for [T; 30]
where T: StableLayout,

Source§

impl<T> StableLayout for [T; 31]
where T: StableLayout,

Source§

impl<T> StableLayout for [T; 32]
where T: StableLayout,

Source§

impl<T> StableLayout for [T; 48]
where T: StableLayout,

Source§

impl<T> StableLayout for [T; 64]
where T: StableLayout,

Source§

impl<T> StableLayout for [T; 96]
where T: StableLayout,

Source§

impl<T> StableLayout for [T; 128]
where T: StableLayout,

Source§

impl<T> StableLayout for [T; 256]
where T: StableLayout,

Source§

impl<T> StableLayout for [T; 512]
where T: StableLayout,

Source§

impl<T> StableLayout for [T; 1024]
where T: StableLayout,

Source§

impl<T> StableLayout for [T; 2048]
where T: StableLayout,

Source§

impl<T> StableLayout for [T; 4096]
where T: StableLayout,

Implementors§