Can there be a decode_without_loss() function in the candid rust crate that throws an error if the decoded structure would lose data in the de-serialization? A decode function that does not support the backwards compatibility features of candid?
The use case is for serialization during upgrades, I want to make sure users of a library in the post_upgrade hook don’t accidentally de-serialize their data onto a struct that would lose data.
Candid is designed for describing interface, and is not a great fit for stable memory upgrade. The opt rule you mentioned is one problem. The other problem is that it doesn’t support sharing. It’s possible that a graph structure can take exponential space in stable memory. Have you considered other serialization format?