Deserializing Binary Data Files in Rust

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.

4 Likes

I've done similar things to manipulate a lastlog via mmap. That also involved bindgen since the structures could technically change over time.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.