As part of answering a question on these forums I ended up giving a fairly detailed description of how you can parse a struct directly from a file (or some other R: std::io::Read
) in order to work with data generated by a C++ program.
While it's definitely not the first thing I'd reach for when doing file formats (while the code is correct, it does use a couple lines of unsafe
), I've had to use this technique a couple times in the past to interface with a legacy Delphi program.
As such, I thought I'd write up a quick blog post explaining how this particular method of serialization works.