Skip to content
This repository was archived by the owner on Aug 15, 2025. It is now read-only.

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

Merged
VictorKoenders merged 2 commits intotrunkfrom
feature/decode_from_slice_with_len
Dec 11, 2021
Merged

[Breaking change] Made all decode_from_slice also return the number of bytes read#445
VictorKoenders merged 2 commits intotrunkfrom
feature/decode_from_slice_with_len

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

@VictorKoenders VictorKoenders requested a review from a user December 9, 2021 08:28
@VictorKoenders VictorKoenders force-pushed the feature/decode_from_slice_with_len branch from d13d7f8 to 2cfe21d Compare December 10, 2021 18:55
@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

@ghost ghost 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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants