Hello everyone,
As the title implies, I'm trying to deserializing from a binary data file which was originally created with Microsoft Visual C++.
Background information
I schedule speakers every week for an organization. I use a program that doesn't have all of the functionality that I would like it to have. The program is written with Visual Studios C++ on a Windows environment. I'm on Linux and run the program via Wine.
The program outputs all the data to a binary file instead of using a database or JSON.
Provided I have a lot of history locked into the data files, I don't want to just walk away from it without the data if I can do something about it.
I'm not a professional programmer, more of a weekend hobbyist.
What I want to achieve
I want to be able to deserialize the data stored within the .dat
binary files so that I can create additional tools that use the data stored in the files. For example, a tool to automatically email speakers when their arrangements approach would be nice.
The .data files
As mentioned before, the program was made with Visual Studios C++. I've contacted the author of the program and asked if he would be willing to write a way to export the data. He said a feature like that is not planned but was kind to give me the structure of each data file (there are a few).
Example of the structure of the speaker data file
speakers.dat
struct spkr {
char name[2][20];
char addr1[40];
char addr2[40];
char phone[16];
char tks[32];
char fts[32];
char ems; // b1 elder; b2 ms; b5 suspended;
char asn;
WORD cng;
WORD num;
WORD xtp;
char blk;
char spr;
char spare[46];
};
An example of what it looks like when I run $ strings
on the speaker .dat
file:
1 │ Aaron
2 │ James
3 │ Chris
4 │ White
5 │ 555-555-5555
6 │ Dave
7 │ Roberts
8 │ Chris
9 │ Rockefeller
10 │ 555-555-5555
[...]
Types
Using A Guide to Porting C/C++ to Rust a reference.
The CPP char type is like a Rust's i8
or u8
and strings are made from an array of chars.
Not sure what a WORD
is.
My question to you all
I have searched around and I've seen a lot of potential solutions ranging from #[repo(c)], bingen, cxx, bincode, and so on.
A lot of conversation is dedicated to using C/Cpp libraries from within Rust but that's not my situation. I only want to deserialize binary file that was made with a C++ application provided I have the structure used in it's creation.
Armed with the information above, how would you tackle this problem?
I'm going to laugh if Serde is the answer...