seekable_reader

Crates.ioseekable_reader
lib.rsseekable_reader
version0.1.2
sourcesrc
created_at2021-11-09 23:44:15.395127
updated_at2021-11-10 11:38:57.973357
descriptionSeek implementation for every Read
homepage
repositoryhttps://github.com/UgnilJoZ/seekable_reader
max_upload_size
id479184
size28,500
Jan Ole Zabel (UgnilJoZ)

documentation

http://docs.rs/seekable_reader

README

Crates.io Documentation Dependency Status

seekable_reader

This crate introduces the SeekableReader, which provides Seek if wrapped around a Read instance.

An example:

use std::io::{Read, Seek, SeekFrom};
use seekable_reader::SeekableReader;

let source = vec![1, 2, 3, 4, 5];
let mut reader = SeekableReader::new(source.as_slice(), 1);
let mut buffer = vec![0; 5];
// Read one byte and seek back
reader.read(&mut buffer[..1]).unwrap();
reader.seek(SeekFrom::Start(0)).unwrap();
// First byte can be read again!
let bytes: Vec<_> = reader.bytes().map(|b| b.unwrap()).collect();
assert_eq!(&source, &bytes);
Commit count: 30

cargo fmt