#io-read #buffer #reader #reverse #buf-reader

read_collection

A collection of different variants of the std::io::Read trait

8 releases

0.1.5 Aug 11, 2024
0.1.4 Aug 10, 2024
0.0.2 Jun 12, 2024

#982 in Parser implementations

Download history 1/week @ 2024-07-26 578/week @ 2024-08-09 39/week @ 2024-08-16 52/week @ 2024-09-13 9/week @ 2024-09-20 42/week @ 2024-09-27 6/week @ 2024-10-04

109 downloads per month

Custom license

66KB
1K SLoC

Read Collection

This crate provides some other variants of the Read trait. Currently there's only ReadBack. Feel free to create PRs for other variants.

Example (ReadBack)

use read_collection::ReadBack;
use std::io::Read;

fn main() {
    let values = [1, 2, 3];
    let mut buffer = [0, 0];

    // How it could look like with `Read`:
    assert_eq!(values.as_slice().read(&mut buffer).ok(), Some(2));
    assert_eq!(buffer, [1, 2]);

    // With `ReadBack`:
    assert_eq!(values.as_slice().read_back(&mut buffer).ok(), Some(2));
    //                 [----] and the buffer contains the value starting from the back!
    assert_eq!(buffer, [2, 3]);
}

Status

Implemented:

  • ReadBack for reading back duh
    • ReadBack trait
    • BufReadBack trait
      • for &[u8]
      • for Empty
      • BufReadBacker struct

Dependencies

~250KB