buffered_read: return empty buffer on eof
This commit is contained in:
parent
0a72e26704
commit
318564ac03
@ -231,6 +231,8 @@ impl <'a> crate::tools::BufferedReader for BufferedArchiveReader<'a> {
|
||||
|
||||
fn buffered_read(&mut self, offset: u64) -> Result<&[u8], Error> {
|
||||
|
||||
if offset == self.archive_size { return Ok(&self.read_buffer[0..0]); }
|
||||
|
||||
let buffer_len = self.read_buffer.len();
|
||||
let index = self.index;
|
||||
|
||||
|
@ -21,8 +21,9 @@ pub mod timer;
|
||||
/// `buffered_read`. It returns a reference to an internal buffer. The
|
||||
/// purpose of this traid is to avoid unnecessary data copies.
|
||||
pub trait BufferedReader {
|
||||
/// This functions tries to fill the internal buffers, then returns
|
||||
/// a reference to the available data.
|
||||
/// This functions tries to fill the internal buffers, then
|
||||
/// returns a reference to the available data. It returns an empty
|
||||
/// buffer if `offset` points to the end of the file.
|
||||
fn buffered_read(&mut self, offset: u64) -> Result<&[u8], Error>;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user