Skip to content

Rust byte reader with a seek-back cache

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

UgnilJoZ/seekable_reader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Crates.io CodeCov 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);

About

Rust byte reader with a seek-back cache

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Languages