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

Method encode

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

Encodes a value as a JSON line. Serializes the item to JSON and appends a newline character. # Errors - if serialization to JSON fails - if writing to the buffer fails

(&mut self, item: T, dst: &mut BytesMut)

Source from the content-addressed store, hash-verified

85 /// - if serialization to JSON fails
86 /// - if writing to the buffer fails
87 fn encode(&mut self, item: T, dst: &mut BytesMut) -> Result<(), Self::Error> {
88 let mut writer = dst.writer();
89 serde_json::to_writer(&mut writer, &item)
90 .map_err(io::Error::from)
91 .attach_opaque(item)?;
92 writeln!(writer)?;
93 Ok(())
94 }
95}
96
97/// Decodes JSON lines into typed values.

Callers 2

Calls 3

OkInterface · 0.85
map_errMethod · 0.80
attach_opaqueMethod · 0.45

Tested by 2