rad crate for r/w
This crate provides neat ways to eat bytes out of your favorite readers and push bytes into cute writers.
This crate has three modules, one for each kind of endianness: be
(big endian), le
(little endian), and ne
(native endian— whatever your system is on)
Examples
Read unsigned 16 bit big-endian integers from a Reader
:
use *; // < note how we specify we want big endian when we import the trait
let mut rdr = &mut &;
assert_eq!;
Write unsigned 16 bit little-endian integers to a Writer
:
use *; // and here we specify little endian
let mut wtr = vec!;
wtr.w.unwrap;
assert_eq!;
Why
These helpers can greatly increase the ease of reading numbers and other things from a file/…
See, to read 3 u64s from a reader, you would have to go through all this trouble:
use Read;
wheras, with this crate, its as simple as
use *;
t.;