Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/larusso/concat-reader
Adapter for reading through multiple reader continuously
https://github.com/larusso/concat-reader
concatenate data-structures reader rust
Last synced: 3 months ago
JSON representation
Adapter for reading through multiple reader continuously
- Host: GitHub
- URL: https://github.com/larusso/concat-reader
- Owner: Larusso
- License: apache-2.0
- Created: 2019-08-16T17:28:30.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-09-12T18:25:28.000Z (over 5 years ago)
- Last Synced: 2024-10-11T10:46:59.323Z (4 months ago)
- Topics: concatenate, data-structures, reader, rust
- Language: Rust
- Size: 12.7 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
concat-reader
=============Adapter for reading through multiple reader continuously
[![Build Status](https://travis-ci.org/Larusso/concat-reader.svg?branch=master)](https://travis-ci.org/Larusso/concat-reader)
[![Crates.io](https://img.shields.io/crates/v/concat-reader.svg)](https://crates.io/crates/concat-reader)`concat-reader` is a library for Rust that contains utility functions and traits to create
concatenated [`Read`] objects from any thing that implements [`IntoIterator`].```rust
use concat_reader::{FileConcatRead, concat_path};
use std::io::{self, Read, BufRead, BufReader, Write};
fn main() -> io::Result<()>{
let files = vec!["/path/to/file_1", "/path/to/file_2", "/path/to/file_3"];
let mut f = concat_path(files);
let mut buffered = BufReader::new(f);
let stdout = io::stdout();
let mut handle = stdout.lock();
loop {
let mut line = String::new();
let r = buffered.read_line(&mut line)?;
if r == 0 {
return Ok(())
}
let f = buffered.get_ref().file_path();
eprintln!("read from {:?}", f);
handle.write(line.as_bytes())?;
}
}
```Documentation: https://docs.rs/concat-reader
license
=======[Apache License 2.0](LICENSE)
[`READ`]: https://doc.rust-lang.org/std/io/trait.Read.html
[`IntoIterator`]: https://doc.rust-lang.org/std/iter/trait.IntoIterator.html