Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/solarliner/buffers
Collection of unified buffers from stdio, file and memory buffers.
https://github.com/solarliner/buffers
Last synced: 7 days ago
JSON representation
Collection of unified buffers from stdio, file and memory buffers.
- Host: GitHub
- URL: https://github.com/solarliner/buffers
- Owner: SolarLiner
- License: mit
- Created: 2019-11-03T10:33:19.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2019-11-03T12:50:28.000Z (about 5 years ago)
- Last Synced: 2024-10-10T20:15:24.742Z (28 days ago)
- Language: Rust
- Size: 6.84 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# buffers
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.## How to use
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.## Example
```rust
use clap::{App, Arg};
use buffers::{Input, Output};let matches = App::new("app")
.arg(Arg::with_name("input").index(1))
.arg(Arg::with_name("output").index(2))
.get_matches();
let mut input_buf = Input::from_arg(matches.value_of("input"));
let mut output_buf = Output::from_arg(matches.value_of("output"));
parse_input(&mut input_buf).and_then(|ast| transpile(ast, &mut output_buf));
```