Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Greatly reduce amount of generated code (#1)
### Changes * A fuzz test ensures* that the fork and the original `serde_cbor` are compatible at the lower level. At the higher level (structs/enums/..), compatibility is ensured by passing all the same tests and also not touching the code. * Add traits and two different implementations for configuring the encoder/encoder. The standard (static) configuration produces very little code as it avoids generating multiple branches in the encoder/decoder for each runtime configuration. * Generate only the strictly required decoder code for each deserialized data type. So if a u64 is to be deserialized, only generate code to deserialize integers and fail for other core entities. This is done via the type system with traits and associated constants. Note that the decoder is the largest source of code bloat. * Tidy up the code generation by reusing code from `ucbor`, which is highly optimized for speed and size. * All non-configurable behavior was retained to allow fuzzing the new implementation against the original `serde_cbor`. This includes the nuances of modeling structs/newtypes/enums atop of the serde data model. * Bugs were also retained. Specifically, disallowing packed encoding will also disallow any maps with integer keys, which isn't strictly correct. Ditto doesn't use packed encoding, so this doesn't affect our usage. I left it as it reduces the number of changes needed to make tests and fuzzer compatible. ### Breaking changes * There's a second generic type argument on the (De)serializer types. * The standard (non-configured) decoder disallows legacy enums by default. * The error messages are slightly different ### Theoretical breaking change * Breaks Deserialize implementations that tell the deserializer they want something but accept something completely different. All reasonable compatibility {str/bytes/seq}, {unsigned/signed/float} compatibilities were implemented to give an extra margin of safety. * Example: if the deserialize implementation calls `deserialize_str(visitor)` but would produce a value if the visitor `visit_u64(..)` was called. That is incompatible with this fork.
- Loading branch information