#adapter #reader #io

concat-reader

Adapter for reading through multiple reader continuously

1 unstable release

0.1.0 Aug 16, 2019

#81 in #adapter

Download history 43/week @ 2025-04-13 60/week @ 2025-04-20 62/week @ 2025-04-27 71/week @ 2025-05-04 49/week @ 2025-05-11 35/week @ 2025-05-18 44/week @ 2025-05-25 52/week @ 2025-06-01 77/week @ 2025-06-08 52/week @ 2025-06-15 71/week @ 2025-06-22 48/week @ 2025-06-29 65/week @ 2025-07-06 72/week @ 2025-07-13 41/week @ 2025-07-20 43/week @ 2025-07-27

223 downloads per month
Used in 2 crates

Apache-2.0

26KB
480 lines

concat-reader

Adapter for reading through multiple reader continuously

Build Status Crates.io

concat-reader is a library for Rust that contains utility functions and traits to create concatenated Read objects from any thing that implements IntoIterator.

  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

No runtime deps