I'm implementing a serde data format for a proprietary binary format. For space saving reasons, structures such as variable-size opaque data and arrays of objects can have their length represented with 1,2, or 4 byte integers. The format is not self-describing, so there's no way for the machine to know where the length integer ends and payload begins without human help.
How could I pass along this information from the site where the human knows it (definition of the particular type to be (de-)serialized) to where it needs to go (my
Deserializer)? Some sort of custom field attribute?
I don't care if the approach renders my data format incompatible with the rest of the ecosystem, as the crate is proprietary anyways. However, I'd prefer not having to maintain a serde fork.