Open Marcono1234 opened 7 months ago
Have implemented this experimentally in the serde-ser-remove-length-validation
branch, however for now I will not merge this since the validation helps with detecting bad Serialize
implementations (assuming the validation is correct).
In case the validation turns out to be incorrect or too strict, I might consider merging this in the future.
Problem solved by the enhancement
Multiple Serde
Serializer
methods take alen
argument, for exampleSerializer::serialize_seq
. Serde JSON does not seem to actually validate this argument, it just checks it to special-case empty containers, see e.g.serialize_seq
for writing toWrite
orserialize_seq
for creating aValue
.Struson currently validates the length and returns a
SerializerError::IncorrectElementsCount
on mismatch. The intention was to help users detect incorrect handwrittenSerialize
implementations. However, this validation causes the following issues:Serialize
(e.g. #41)Enhancement description
Remove the validation of the expected length, and remove
SerializerError::IncorrectElementsCount
Alternatives / workarounds
Fix the bugs in the current length checks, and verify that it behaves correctly for derived
Serialize