binary_rw

Crates.iobinary_rw
lib.rsbinary_rw
version4.1.0
sourcesrc
created_at2018-12-17 16:17:10.601296
updated_at2024-06-09 17:48:09.468105
descriptionA binary reader/writer library for rust
homepage
repositoryhttps://github.com/mathias234/binary_rw
max_upload_size
id102369
size47,403
Mathias Danielsen (mathias234)

documentation

README

binary_rw

Crate GitHub Workflow Status Coverage Status

A binary reader/writer for the rust language, with a similar syntax to the C# BinaryWriter and BinaryReader

Examples

Example code for reading

extern crate binary_rw;
use binary_rw::{
    filestream::{Filestream, OpenType},
    BinaryReader
};

fn main() {
  let mut fs = Filestream::new("test.bin", OpenType::Open).expect("Failed to open file"); 
  let mut binary_file = BinaryReader::new(&mut fs);

  let read_value = binary_file.read_f32().expect("Failed to read f32");
  println!("{:?}", read_value);
}

Example code for writing

extern crate binary_rs;
use binary_rs::{
    filestream::{Filestream, OpenType},
    BinaryReader
};

fn main() {
  let mut fs = Filestream::new("test.bin", OpenType::OpenAndCreate).expect("Failed to open file"); 
  let mut binary_file = BinaryWriter::new(&mut fs);
  
  let value: f32 = 30.5;
  binary_file.write_f32(value).expect("Failed to write f32");
}

TODO

Commit count: 90

cargo fmt