Serde: Pass out-of-band data to custom Deserializer

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.

Are you looking for DeserializeSeed?

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.