devela::_dep::bytemuck::checked

Function try_pod_read_unaligned

pub fn try_pod_read_unaligned<T>(bytes: &[u8]) -> Result<T, CheckedCastError> 
Available on crate feature dep_bytemuck only.
Expand description

Reads from the bytes as if they were a T.

§Failure

  • If the bytes length is not equal to size_of::<T>().
  • If the slice contains an invalid bit pattern for T