#endian #byte-stream #stream #little #byte #little-endian

le-stream

De-/serialize objects from/to little endian byte streams

6 releases

new 0.5.0 Apr 8, 2025
0.4.3 Oct 16, 2024
0.4.0 Sep 22, 2024
0.3.5 Sep 21, 2024
0.1.8 Sep 19, 2024

#1467 in Encoding

Download history 16/week @ 2025-02-08 16/week @ 2025-02-15 101/week @ 2025-04-05

101 downloads per month

MIT license

22KB
491 lines

A library for reading and writing data in little-endian byte order.


le-stream

Serialize and deserialize object to/from little-endian byte streams.

Example

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));
}

Contribution guidelines

  • Use cargo fmt
  • Check code with cargo clippy

Dependencies

~210KB