le-stream

Crates.iole-stream
lib.rsle-stream
version0.4.3
sourcesrc
created_at2024-09-18 13:47:27.134725
updated_at2024-10-16 18:21:58.206635
descriptionDe-/serialize objects from/to little endian byte streams
homepage
repositoryhttps://github.com/PaulmannLighting/le-stream
max_upload_size
id1379305
size29,352
Richard Neumann (neumann-paulmann)

documentation

https://docs.rs/le-stream

README

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
Commit count: 136

cargo fmt