feat: Add buffering to File reader

pull/24376/head
Jake Goulding 2022-11-18 16:20:56 -05:00 committed by Carol (Nichols || Goulding)
parent 5be0315db9
commit 51aa2a118b
No known key found for this signature in database
GPG Key ID: E907EE5A736F87D4
1 changed files with 3 additions and 2 deletions

View File

@ -571,16 +571,17 @@ mod blocking {
use snafu::prelude::*;
use std::{
fs::File,
io::{self, Read},
io::{self, BufReader, Read},
path::{Path, PathBuf},
};
pub struct SegmentFileReader<R>(R);
impl SegmentFileReader<File> {
impl SegmentFileReader<BufReader<File>> {
pub fn from_path(path: impl AsRef<Path>) -> Result<Self> {
let path = path.as_ref();
let f = File::open(path).context(UnableToOpenFileSnafu { path })?;
let f = BufReader::new(f);
Ok(Self::new(f))
}
}