Crates.io | byteorder-pack |
lib.rs | byteorder-pack |
version | 0.1.0 |
source | src |
created_at | 2022-04-24 05:17:30.272792 |
updated_at | 2022-04-24 05:17:30.272792 |
description | A binary data reader and writer that is similar to Python's struct module |
homepage | |
repository | https://github.com/chengyuhui/byteorder-pack |
max_upload_size | |
id | 572966 |
size | 12,436 |
A binary data reader and writer that is similar to Python's struct module, but makes use of Rust's typing system.
use std::io::Cursor;
use byteorder_pack::UnpackFrom;
let mut cursor = Cursor::new(vec![0x01, 0x02, 0x00, 0x03, 0x00, 0x04]);
let (a, b, cd) = <(u8, u8, [u16; 2])>::unpack_from_be(&mut cursor).unwrap();
assert_eq!(a, 1);
assert_eq!(b, 2);
assert_eq!(cd, [3, 4]);