chain-reader 1.0.0

Combining multiple [`Read`] instances into a sequential read pipeline with configurable error handling
Documentation
  • Coverage
  • 90.91%
    10 out of 11 items documented1 out of 6 items with examples
  • Size
  • Source code size: 13.38 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.77 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 14s Average build duration of successful builds.
  • all releases: 11s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Meow0x7E/chain-reader
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Meow0x7E

chain-reader

A Rust library for sequentially chaining multiple [Read] instances with configurable error handling.

Features

  • Dynamic Reader Chaining: Combine multiple readers (including from iterators) into a single sequential read pipeline
  • Configurable Error Handling: Define custom strategies for handling I/O errors using the [ErrorAction] enum
  • Automatic Advancement: Automatically progresses to the next reader on EOF
  • FIFO Processing: Processes readers in first-in-first-out order

Comparison with std::io::Chain

  • Supports dynamic addition of readers (not limited to two fixed readers)
  • Provides flexible error handling strategies
  • Handles both single readers and iterators of readers
  • Automatically advances on EOF (no need for manual checking)

Usage

use chain_reader::{ChainReader, ErrorAction};
use std::io::{self, Read};

let mut chain = ChainReader::new(|e| match e.kind() {
    io::ErrorKind::Interrupted => ErrorAction::Retry,
    _ => ErrorAction::RetryAndSkip,
});

chain.push(io::stdin());
chain.push_iter(vec![
    io::Cursor::new("hello "),
    io::Cursor::new("world!"),
]);

let mut content = String::new();
chain.read_to_string(&mut content)?;