Skip to main content

Module pod

Module pod 

Source
Expand description

Substrate-level Pod marker.

Every zero-copy access path, including the native substrate, requires a Pod bound rather than the loose T: Copy. This module is that marker.

§Hopper-owned safety

Zeroable and Pod are Hopper-owned marker traits. Hopper macros emit field-level proof blocks that require every field to already implement Hopper Pod before the containing layout receives its own impl. That gives the same useful rejection points users got from the old dependency-backed path while keeping the proof surface inside the framework:

  • bool, char, references, not all bit patterns valid
  • padded #[repr(C)] structs, padding bytes aren’t accounted for
  • non-alignment-1 primitives when alignment-1 was claimed
  • enums with niches and non-zero variants

Hopper’s #[hopper::pod] derive and #[hopper::state] macro emit these field-level proofs, so layouts can use the Hopper-owned marker directly.

See hopper_runtime::pod::Pod (downstream re-export) for the runtime-side view.

Traits§

Pod
Marker for types that can be safely overlaid as &T / &mut T on raw account bytes at any offset.
ValuePod
Marker for Copy + Sized scalars/arrays that may be read by value from raw bytes with read_unaligned_value (alignment-independent).
Zeroable
Marker for Copy + Sized values that are valid for every bit pattern.

Functions§

read_unaligned_value
Read a ValuePod scalar/array out of bytes at offset by value, tolerating any alignment (uses core::ptr::read_unaligned).