Description
There are use cases where embedding binary data into an XML document is convenient. Although not officially supported by the XML spec there are valid and popular uses that exist in the wild (e.g. VTK). Binary VTK files are quite common, in fact the tag (which can contain binary data) is the default when writing vtk files, and there are plenty of files like this in the wild.
In the past quick-xml
was able to support binary data, but this has changed and in the current state requires some non-trivial changes for adding support for being able to write and read uninterpreted binary data.
My first attempt didn't really address the issue correctly since binary data can have valid '<' and '>' tags, which can trip up the parser, meaning that at least reading must be augmented from the lowest level (probably as part of Reader
).
As discussed previously the implementation for this should work as an additional feature.
Reading
I think it is not difficult to add a customization point for the reader in quick-xml
without being too invasive by adding a "context" field (supplied externally) to Reader that can call ask how many bytes should be read by feeding it context about what has already been read.
Writing
All types in the serialize part of the code is bound by fmt::Write
. I haven't found a way to maintain that bound everywhere and also support for writing binary files to an optional or custom io::Write
type. To enable this I think we have to switch back to io::Write
. I understand that there are some performance concerns about having to write to a buffer if io::Write
is used, but I don't see another way of adding support for binary writing without io::Write
. I can really use some help from the maintainers to address this point.