Read the next Avro value from the file, if one exists.
(&mut self)
| 232 | #[inline] |
| 233 | /// Read the next Avro value from the file, if one exists. |
| 234 | pub fn read_next(&mut self) -> Result<Option<Value>, AvroError> { |
| 235 | if self.is_empty() { |
| 236 | self.read_block_next()?; |
| 237 | if self.is_empty() { |
| 238 | return Ok(None); |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | let mut block_bytes = &self.buf[self.buf_idx..]; |
| 243 | let b_original = block_bytes.len(); |
| 244 | let schema = self.schema(); |
| 245 | let item = from_avro_datum(schema, &mut block_bytes)?; |
| 246 | self.buf_idx += b_original - block_bytes.len(); |
| 247 | self.messages_remaining -= 1; |
| 248 | Ok(Some(item)) |
| 249 | } |
| 250 | |
| 251 | fn is_empty(&self) -> bool { |
| 252 | self.messages_remaining == 0 |
no test coverage detected