Skip to content

structio 0.2.0

Choose a tag to compare

@stephenberry stephenberry released this 02 Sep 12:39
· 43 commits to main since this release

Writing a document after what a buffer already holds, in JSON as well as BEVE, and a buffer that survives a panic out of the value being written.

[dependencies]
structio = "0.2"

Added

  • json::append(&T, &mut Vec<u8>) writes a document after what a buffer already holds, the counterpart of beve::append. write_into replaces a buffer's contents, so a value that has to sit behind a protocol header, or behind the entries already in a listing, needed a second buffer and a copy out of it. json::Writer::appending is the same thing with the writer in hand.

Changed

  • json::append, beve::append and beve::append_aligned leave the buffer exactly as they found it if writing the value panics. The buffer moves into the writer, so an unwind used to drop it along with the bytes in front of the document. A Write impl may panic by design: an adapter whose target has values it cannot encode is told to substitute or panic. write_into still leaves its buffer empty there, its contents being the call's to replace, and now says so.
  • json::Writer::into_string checks the bytes handed to Writer::appending, and panics if they are not UTF-8. Every other byte in the buffer is UTF-8 by construction; those are the only ones the writer did not produce. Use into_vec to append JSON behind a binary prefix.

The full list is in CHANGELOG.md.