iter: remove the truncated case

fixes test::write_many
master
Astro 2020-12-11 00:43:46 +01:00
parent 1a35d195e6
commit c0da68f48c
2 changed files with 1 additions and 4 deletions

View File

@ -20,7 +20,6 @@ impl<B> From<WriteError<B>> for Error<B> {
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ReadError {
Truncated { offset: usize },
InvalidSize { offset: usize, size: usize },
MissingSeparator { offset: usize },
Utf8Error(str::Utf8Error),
@ -29,8 +28,6 @@ pub enum ReadError {
impl fmt::Display for ReadError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
&ReadError::Truncated { offset }=>
write!(f, "truncated record at offset {}", offset),
&ReadError::InvalidSize { offset, size } =>
write!(f, "invalid record size {} at offset {}", size, offset),
&ReadError::MissingSeparator { offset } =>

View File

@ -20,7 +20,7 @@ impl<'a> Iterator for Iter<'a> {
let data = &self.data[self.offset..];
if data.len() < 4 {
return Some(Err(ReadError::Truncated { offset: self.offset }))
return None;
}
let record_size = BigEndian::read_u32(data) as usize;