use lightpack::{Size, Pack, Unpack, byteorder::BigEndian}; #[derive(Size, Pack, Unpack, Debug)] struct Point { x: i16, y: i16, } fn main() { let mut buffer = [0u8; Point::SIZE]; Point { x: 3, y: 4 }.pack::(&mut buffer); println!("{:?}", buffer); // => [0, 3, 0, 4] let point = Point::unpack::(&[0, 3, 0, 4]).unwrap(); println!("{:?}", point); // => Point { x: 3, y: 4 } }