multi-readers

Crates.iomulti-readers
lib.rsmulti-readers
version0.3.0
sourcesrc
created_at2023-12-04 05:45:09.920836
updated_at2024-10-31 06:05:15.575898
descriptionCombining multiple readers
homepage
repositoryhttps://github.com/cradiy/multi-readers.git
max_upload_size
id1057249
size21,521
Cradiy (cradiy)

documentation

README

Crate Info

Multiple Readers

multiple-readers is a Rust library aimed at simplifying the process of combining multiple types that implement the std::io::Read trait into a unified reader.

Features

  • Combines multiple types that implement the std::io::Read trait into a unified reader.
  • Can read from data sources sequentially until all data sources are exhausted.
  • Supports tokio ( Unstable )

Example

use multi_readers::join_readers;
use std::io::{Cursor, Read};
fn main() -> std::io::Result<()> {

    let slice = Cursor::new(b"First-");
    let bytes = Cursor::new(b"Second-");
    let mut reader = join_readers!(slice, bytes);
    let mut buf = String::new();
    reader.read_to_string(&mut buf)?;
    assert_eq!(buf.as_str(), "First-Second-");
    Ok(())
}

Commit count: 62

cargo fmt