| 1428 | type Item = T; |
| 1429 | |
| 1430 | fn next(&mut self) -> Option<Self::Item> { |
| 1431 | loop { |
| 1432 | // If we currently have some bytes in the buffer to still decode, do that. |
| 1433 | if (&self.reader).remaining() > 0 { |
| 1434 | let row = bsatn::from_reader(&mut &self.reader).expect("Failed to decode row!"); |
| 1435 | return Some(row); |
| 1436 | } |
| 1437 | |
| 1438 | // Don't fetch the next chunk if there is none. |
| 1439 | if self.inner.is_exhausted() { |
| 1440 | return None; |
| 1441 | } |
| 1442 | |
| 1443 | // Otherwise, try to fetch the next chunk while reusing the buffer. |
| 1444 | self.reader.buf.clear(); |
| 1445 | self.reader.pos.set(0); |
| 1446 | self.inner.read(&mut self.reader.buf); |
| 1447 | } |
| 1448 | } |
| 1449 | } |