You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Multiple Serde Serializer methods take a len argument, for example Serializer::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 to Write or serialize_seq for creating a Value.
Struson currently validates the length and returns a SerializerError::IncorrectElementsCount on mismatch. The intention was to help users detect incorrect handwritten Serialize implementations. However, this validation causes the following issues:
It might be too strict, maybe the length is only an estimation or upper bound in some cases (?)
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. Serialization does not work with
serde_with::skip_serializing_none
#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
The text was updated successfully, but these errors were encountered: