Collection of unified buffers from stdio, file and memory buffers.
The buffers
crate unifies standard IO, memory and file buffers into a unified type, allowing
to effectively leave the type of buffer used to the user.
The buffers
crate exposes three types; one for input, one for output, and one for duplex in/out
operations. For convenience, each type has a from_arg
constructor that takes in the output of
a commandline parser (such as clap
) and returns the buffer of the appropriate type (see the
function docs for more details).
IO Read/Write traits are implemented for the types meaning you can use those wrapper types as a drop-in replacement of "regular" buffers.
```rust use clap::{App, Arg}; use buffers::{Input, Output};
let matches = App::new("app") .arg(Arg::withname("input").index(1)) .arg(Arg::withname("output").index(2)) .getmatches(); let mut inputbuf = Input::fromarg(matches.valueof("input")); let mut outputbuf = Output::fromarg(matches.valueof("output")); parseinput(&mut inputbuf).andthen(|ast| transpile(ast, &mut output_buf)); ```