binary-util 0.3.1-rc.1

A panic-free binary utility crate to read/write binary streams over the wire.
Documentation
binary-util-0.3.1-rc.1 has been yanked.

binary_util

A panic-free binary utility crate to read/write binary streams over the wire.

Documentation | Discord

Generic Usage

use binary_util::{BinaryIo, BinaryReader, BinaryWriter};

#[derive(BinaryIo)]
pub struct MyStruct {
    pub a: u32,
    pub b: u32,
}

fn main() {
    let mut writer = BinaryWriter::new();
    let my_struct = MyStruct { a: 1, b: 2 };
    if let Err(_) = writer.write(&my_struct) {
        println!("Failed to write MyStruct");
    }

    let mut reader = BinaryReader::from(writer);
    if let Ok(my_struct2) = MyStruct::read(&mut reader) {
        assert_eq!(my_struct, my_struct2);
    } else {
        println!("Failed to read MyStruct");
    }
}

For more examples and usage, please refer to the Documentation.