Skip to content
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

[Breaking change] Made all decode_from_slice also return the number of bytes read #445

Merged
merged 2 commits into from
Dec 11, 2021

Conversation

VictorKoenders
Copy link
Contributor

Currently there is no way to know how many bytes are read when decoding from a slice. This will make it harder to read multiple entries from a blob without encoding the length. This PR makes all decode_from_slice functions return the amount of bytes read.

This is a breaking change, but we're still on alpha so this should be okay.

Also fixes some of the new clippy warnings. This will conflict with #443 but we'll fix that when we get there

@codecov-commenter
Copy link

codecov-commenter commented Dec 11, 2021

Codecov Report

Merging #445 (8fca53f) into trunk (240558d) will increase coverage by 0.24%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##            trunk     #445      +/-   ##
==========================================
+ Coverage   62.87%   63.12%   +0.24%     
==========================================
  Files          46       46              
  Lines        3456     3479      +23     
==========================================
+ Hits         2173     2196      +23     
  Misses       1283     1283              
Impacted Files Coverage Δ
derive/src/parse/generics.rs 62.45% <ø> (ø)
src/de/impl_core.rs 53.57% <ø> (ø)
src/de/read.rs 70.37% <ø> (ø)
src/features/serde/de_owned.rs 0.00% <ø> (ø)
src/lib.rs 100.00% <100.00%> (ø)
tests/alloc.rs 100.00% <100.00%> (ø)
tests/basic_types.rs 99.09% <100.00%> (+0.06%) ⬆️
tests/derive.rs 100.00% <100.00%> (ø)
tests/issues/issue_431.rs 100.00% <100.00%> (ø)
tests/std.rs 100.00% <100.00%> (ø)
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 240558d...8fca53f. Read the comment docs.

Copy link
Collaborator

@ZoeyR ZoeyR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really like returning the tuple, but the only alternative would be to make the decode_from_slice function take a mutable reference, which is more restrictive than it need be.

@VictorKoenders VictorKoenders force-pushed the feature/decode_from_slice_with_len branch from 7220034 to 8fca53f Compare December 11, 2021 14:49
@VictorKoenders VictorKoenders merged commit a067d1e into trunk Dec 11, 2021
@VictorKoenders VictorKoenders deleted the feature/decode_from_slice_with_len branch December 11, 2021 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants