dynamis_abi/decode.rs
1use bytemuck::{Pod, pod_read_unaligned};
2use std::mem::size_of;
3
4pub fn decode<T: Pod>(bytes: &[u8]) -> Vec<T> {
5 let width = size_of::<T>();
6 assert!(
7 bytes.len().is_multiple_of(width),
8 "readback is not a whole number of records"
9 );
10 bytes
11 .chunks_exact(width)
12 .map(|chunk| pod_read_unaligned(chunk))
13 .collect()
14}