Skip to content
Discussion options

You must be logged in to vote

Hi, thanks for your question!

Generally, the best way to handle a file format where there are different versions of the same data is to create one “master” format that you expose to application code, write one struct for each different version of the serialised data, and write impl From<VariantStruct> for MasterStruct implementations to convert the variant structs to/from the master format.

For a format where data is either 32-bit or 64-bit in a consistent way, you can write a single generic struct Data<T>, use T for those 32/64 fields, and then parse either Data<u32> or Data<u64> according to the header. It might look something like this:

struct Properties {
  /* … existing stuff … */
  #[

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@seanlacey
Comment options

@csnover
Comment options

csnover Jul 15, 2025
Collaborator

Answer selected by seanlacey
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants