buffered_read: return empty buffer on eof

This commit is contained in:
Dietmar Maurer 2019-01-06 09:17:28 +01:00
parent 0a72e26704
commit 318564ac03
2 changed files with 5 additions and 2 deletions

View File

@ -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;

View File

@ -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>;
}