paritytech / parity-scale-codec

Lightweight, efficient, binary serialization and deserialization codec
Apache License 2.0
243 stars 95 forks source link

Refactor implementation of `Decode::skip` and `Decode::encoded_fixed_size` #587

Open kalaninja opened 3 months ago

kalaninja commented 3 months ago

By default, Input::skip does an actual read and discards the result, implementors should provide a specialized implementation.

By default, Decode::skip executes Input::skip for types providing Decode::encoded_fixed_size. Otherwise, it is just calling Decode::decode., so implementors should provide a specialized implementation.

As discussed in previous attempts that I found on github, Decode::skip shouldn't validate the input data, providing a fast forward functionality instead. IMHO if a calling code wants to check for data integrity they can manually do something like let _ = Decode::decode(input)?;

Closes #208 Closes #244

kalaninja commented 3 months ago

@ggwpez @bkchr guys, what do you think about this?