Skip to main content

Pod

Trait Pod 

Source
pub unsafe trait Pod:
    Sized
    + Copy
    + Pod
    + Zeroable { }
Expand description

Marker for types that can be safely overlaid on raw account bytes.

§Safety

Implementing Pod for a type T asserts all of:

  1. Every [u8; size_of::<T>()] bit pattern decodes to a valid T.
  2. align_of::<T>() == 1.
  3. T contains no padding.
  4. T contains no internal pointers or references.

With feature = "bytemuck" on (default), the trait is sealed so callers must also prove T: bytemuck::Pod + bytemuck::Zeroable, which gets them obligations 1, 3, and 4 mechanically via bytemuck’s derive. Obligation 2 (alignment) is still a Hopper-specific constraint enforced by the #[hopper::pod] / #[hopper::state] compile-time asserts.

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 Pod for i8

Source§

impl Pod for i16

Source§

impl Pod for i32

Source§

impl Pod for i64

Source§

impl Pod for i128

Source§

impl Pod for u8

Source§

impl Pod for u16

Source§

impl Pod for u32

Source§

impl Pod for u64

Source§

impl Pod for u128

Source§

impl Pod for ()

Source§

impl<const N: usize> Pod for [u8; N]

Implementors§