Trait Flat

Source
pub unsafe trait Flat:
    FlatBase
    + FlatUnsized
    + FlatValidate { }
Expand description

Flat type.

If you want to implement this type for your custom type it’s recommended to use safe #[flat] attribute macro instead.

§Safety

By implementing this trait by yourself you guarantee:

  • Self has stable binary representation that will not change in future. (But the representation could be differ across different platforms. If you need stronger guarantees consider using Portable types.)
  • Self don’t own any resources outside of it.
  • Self could be trivially copied as bytes. (We cannot require Self: Copy because it ?Sized.)
  • All methods of dependent traits have proper implementation and will not cause an UB.

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 Flat for Bool

Source§

impl Flat for f32

Source§

impl Flat for f64

Source§

impl Flat for i8

Source§

impl Flat for i16

Source§

impl Flat for i32

Source§

impl Flat for i64

Source§

impl Flat for i128

Source§

impl Flat for isize

Source§

impl Flat for u8

Source§

impl Flat for u16

Source§

impl Flat for u32

Source§

impl Flat for u64

Source§

impl Flat for u128

Source§

impl Flat for ()

Source§

impl Flat for usize

Source§

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

Source§

impl<T, L> Flat for GenericVec<[MaybeInvalid<T>], L>
where T: Flat, L: Flat + Length,

Source§

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

Source§

impl<const BE: bool, const N: usize> Flat for Float<BE, N>

Source§

impl<const BE: bool, const N: usize, const S: bool> Flat for Int<BE, N, S>

Implementors§