Added buffered IO

And updated tests to reflect this
This commit is contained in:
Jamie Hardt
2021-01-02 12:23:08 -08:00
parent b7f82a9d63
commit 634c21dc9a
4 changed files with 25 additions and 7 deletions

View File

@@ -13,7 +13,7 @@ use super::chunks::ReadBWaveChunks;
use super::cue::Cue;
use std::io::Cursor;
use std::io::{Read, Seek};
use std::io::{Read, Seek, BufReader};
@@ -68,13 +68,22 @@ pub struct WaveReader<R: Read + Seek> {
pub inner: R,
}
impl WaveReader<BufReader<File>> {
pub fn open(path: &str) -> Result<Self, ParserError> {
let f = File::open(path)?;
let inner = BufReader::new(f);
Ok( Self::new(inner)? )
}
}
impl WaveReader<File> {
/// Open a file for reading.
/// Open a file for reading with unbuffered IO.
///
/// A convenience that opens `path` and calls `Self::new()`
pub fn open(path: &str) -> Result<Self, ParserError> {
pub fn open_unbuffered(path: &str) -> Result<Self, ParserError> {
let inner = File::open(path)?;
return Ok( Self::new(inner)? )
}