rwtypes 0.1.0

Adds methods to read/write binary numbers to the Read and Write traits
Documentation
  • Coverage
  • 94.59%
    35 out of 37 items documented0 out of 36 items with examples
  • Size
  • Source code size: 10.09 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.64 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • Homepage
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • zeozeozeo

Adds methods to read/write binary numbers to the Read and Write traits.

This is a simple crate that adds methods like read_u8, read_u32_le, read_u64_be, write_i128_le, write_u16_be, ... to the Rust Read and Write traits.

The impl feature includes the implementations for the WriterTypes and ReaderTypes traits. It is enabled by default.

Example

Reading

// read u32 (4 bytes) from a file in little endian.
let num = f.read_u32_le().unwrap();
// read i64 (8 bytes) from a file in big endian.
let num = f.read_i64_be().unwrap();

Writing

// write u32 (4 bytes) to a file in little endian.
let num = f.write_u32_le(0xdeadbeef).unwrap();
// write i128 (16 bytes) to a file in big endian.
let num = f.write_i64_be(12345).unwrap();

This works with any type that implements Read or Write.

License

Public domain (Unlicense)