-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor implementation of Decode::skip
and Decode::encoded_fixed_size
#587
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
When skipping we wouldn't do the descend_ref
/ascend_ref
. I don't if this is an issue.
I don't know if tests really test for skip
, encoded_fixed_size
.
Ideally we should have for every types, a bunch of value, with the expected encoded_fixed_size
, then we test decode, skip and encoded_fixed_size.
# Conflicts: # src/codec.rs
I added some tests on your branch |
Thinking about I think we can call them, or we can just have a comment on the skip specification saying, skip doesn't take into account But at a first glance implementing skip with WDYT? |
Yes, I agree |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, I added a minor test.
Hey @gui1117 |
Input::skip
Decode::encoded_fixed_size
Decode::skip
By default,
Input::skip
does an actual read and discards the result, implementors should provide a specialized implementation.By default,
Decode::skip
executesInput::skip
for types providingDecode::encoded_fixed_size
. Otherwise, it is just callingDecode::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 likelet _ = Decode::decode(input)?;
Closes #208
Closes #244