Decodes any remaining data when the stream has ended. # Errors - if reading the line fails - if the JSON content is invalid - if the JSON doesn't match type `T`
(&mut self, buf: &mut BytesMut)
| 218 | /// - if the JSON content is invalid |
| 219 | /// - if the JSON doesn't match type `T` |
| 220 | fn decode_eof(&mut self, buf: &mut BytesMut) -> Result<Option<Self::Item>, Self::Error> { |
| 221 | self.lines |
| 222 | .decode_eof(buf) |
| 223 | .inspect(|_| { |
| 224 | self.current_line += 1; |
| 225 | }) |
| 226 | .map_err(io::Error::other)? |
| 227 | .filter(|line| !line.is_empty()) |
| 228 | .map(|line| { |
| 229 | serde_json::from_str(&line) |
| 230 | .map_err(io::Error::from) |
| 231 | .attach_with(|| format!("line in input: {}", self.current_line)) |
| 232 | .attach_with(|| line.clone()) |
| 233 | }) |
| 234 | .transpose() |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | #[cfg(test)] |