Skip to main content

Crate pina_pod_primitives

Crate pina_pod_primitives 

Source
Expand description

Alignment-safe primitive wrappers that can be used in Pod structs.

Pod types (PodU64, PodU32, etc.) wrap native integers in [u8; N] arrays, guaranteeing alignment 1. This allows direct pointer casts from account data without alignment concerns — critical for #[repr(C)] zero-copy structs on Solana.

§Arithmetic

Arithmetic operators (+, -, *) use wrapping semantics in release builds for CU efficiency and panic on overflow in debug builds. Use checked_add, checked_sub, checked_mul, checked_div where overflow must be detected in all build profiles.

§Constants

Each Pod integer type provides ZERO, MIN, and MAX constants.

Macros§

impl_int_conversion
Implements bidirectional conversion between a Pod* wrapper type and its corresponding standard integer.

Structs§

PodBool
The standard bool is not a Pod, define a replacement that is.
PodI16
An alignment-1 wrapper around i16 stored as [u8; 2].
PodI32
An alignment-1 wrapper around i32 stored as [u8; 4].
PodI64
An alignment-1 wrapper around i64 stored as [u8; 8].
PodI128
An alignment-1 wrapper around i128 stored as [u8; 16].
PodU16
An alignment-1 wrapper around u16 stored as [u8; 2].
PodU32
An alignment-1 wrapper around u32 stored as [u8; 4].
PodU64
An alignment-1 wrapper around u64 stored as [u8; 8].
PodU128
An alignment-1 wrapper around u128 stored as [u8; 16].