Crates.io | le-stream |
lib.rs | le-stream |
version | 0.4.3 |
source | src |
created_at | 2024-09-18 13:47:27.134725 |
updated_at | 2024-10-16 18:21:58.206635 |
description | De-/serialize objects from/to little endian byte streams |
homepage | |
repository | https://github.com/PaulmannLighting/le-stream |
max_upload_size | |
id | 1379305 |
size | 29,352 |
Serialize and deserialize object to/from little-endian byte streams.
use le_stream::{FromLeStream, ToLeStream};
fn main() {
let i: i32 = 1234;
let bytes: [u8; 4] = [0xd2, 0x04, 0x00, 0x00];
for (byte, target) in i.to_le_stream().zip(bytes) {
assert_eq!(byte, target);
}
let bytes: [u8; 4] = [0xd2, 0x04, 0x00, 0x00];
let target: i32 = 1234;
assert_eq!(i32::from_le_stream(&mut bytes.into_iter()), Some(target));
}
cargo fmt
cargo clippy