qread 0.1.0

A convenience library for common read operations
Documentation
  • Coverage
  • 100%
    7 out of 7 items documented1 out of 7 items with examples
  • Size
  • Source code size: 9.18 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.23 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 10s Average build duration of successful builds.
  • all releases: 10s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • joshua-laughner

QRead

The "Q" is for "Quick".

QRead is convenience library for common read operations. In Rust, the standard library Read and BufRead traits expose many methods that require you to pass in a mutable reference to a buffer (either a Vec<u8> or String) that it will store the data read into. Often, you will find yourself repeating the pattern of creating a Vec or String just to pass it into these methods. This can become inconvenient if you need to repeat this pattern many times.

QRead addresses this by adding two new methods (read_all_to_bytes and read_all_to_string) to all objects implementing the Read trait and two other new methods (read_until_to_bytes and read_line_to_string) to all objects implementing the BufRead trait. These methods internally just call the most common methods on Read or BufRead after creating the Vec or String for you:

use std::fs::File;
use qread::QRead;

// This assumes that we have a file `demo.txt` in the current directory
let mut f2 = File::open("demo.txt").unwrap();
let text = f2.read_all_to_string().unwrap();

See the docs for more examples.