read_struct

Function read_struct 

Source
pub unsafe fn read_struct<T>(buffer: &[u8], offset: usize) -> T
where T: Copy,
Expand description

Helper to safely read a struct from a byte buffer at an offset

ยงSafety

Caller must ensure:

  • offset + size_of::<T>() <= buffer.len()
  • Buffer is properly aligned for T
  • Bytes represent a valid T