Skip to main content

read_unaligned_value

Function read_unaligned_value 

Source
pub fn read_unaligned_value<T>(
    bytes: &[u8],
    offset: usize,
) -> Result<T, ProgramError>
where T: ValuePod,
Expand description

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

Returns Err(AccountDataTooSmall) if the range is out of bounds. This is the correct path for native multi-byte integers, which must never be formed as a &T reference at an arbitrary offset.