MCPcopy Create free account
hub / github.com/hashintel/hash / decode_eof

Method decode_eof

libs/@local/codec/src/bytes.rs:220–235  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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)]

Callers 1

Calls 6

map_errMethod · 0.80
mapMethod · 0.45
filterMethod · 0.45
is_emptyMethod · 0.45
attach_withMethod · 0.45
cloneMethod · 0.45

Tested by 1