[][src]Trait concat_reader::ConcatRead

pub trait ConcatRead: Read {
    type Item;
    fn skip(&mut self) -> bool;
fn current(&self) -> Option<&Self::Item>; }

A special Read trait for concatenated readers.

This traids adds special function to fetch the current Read item and to skip to the next item.

Associated Types

type Item

Loading content...

Required methods

fn skip(&mut self) -> bool

Skips to the next Read item in the internal Iterator.

use concat_reader::concat;
use std::io::{self, Read};
use crate::concat_reader::ConcatRead;

fn main() -> io::Result<()> {
    let value1 = "some string".as_bytes();
    let value2 = "another string".as_bytes();

    let mut buffer = [0; 4];
    let mut f = concat(vec![value1, value2]);
    f.read_exact(&mut buffer)?;
    assert_eq!(buffer, "some".as_bytes());

    //skip to the next Read object
    f.skip();
    f.read_exact(&mut buffer)?;
    assert_eq!(buffer, "anot".as_bytes());
    Ok(())
}

fn current(&self) -> Option<&Self::Item>

Returns the current Read item in the internal iterator being read from.

Loading content...

Implementors

impl<I> ConcatRead for FileConcatReader<I> where
    I: IntoIterator,
    I::Item: AsRef<Path>, 
[src]

type Item = File

impl<I> ConcatRead for ConcatReader<I> where
    I: IntoIterator,
    I::Item: Read
[src]

type Item = I::Item

Loading content...