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

digest: Clarify panic safety of (Block)Digest::finish #2185

Merged
merged 5 commits into from
Dec 17, 2024

Conversation

briansmith
Copy link
Owner

See the individual commit messages for details. This is a step towards providing a never-panicking variant of the API.

Although the buffer does initially contain the pending data,
`pending` is a confusing name for it.
Istead of forcing callers to slice the buffer to the block
length and then asserting that they did so, just have
`BlockContext::finish` do the slicing itself. (It already
was.)
Help the compiler understand the range of `len_len` so it can
optimize away some bounds checks.
Clarify that the slicing will panic if (and only if) the function's
precondition is violated.

This is a step towards providing an non-panicking variant of the API.
Return an error instead of panic when too much input is
processed by a `BlockContext`, or when the precondition of
`BlockContext::finish` is violated. Jump through some hoops
to get the compiler to prefer the non-error path.

This is a step towards providing an non-panicking variant of
the API.
@briansmith briansmith force-pushed the b/digest-infallible-1 branch from b4d440d to b967bdf Compare December 16, 2024 18:43
Copy link

codecov bot commented Dec 16, 2024

Codecov Report

Attention: Patch coverage is 86.36364% with 9 lines in your changes missing coverage. Please review.

Project coverage is 96.90%. Comparing base (9baba60) to head (b967bdf).
Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
src/digest.rs 83.92% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2185      +/-   ##
==========================================
- Coverage   96.95%   96.90%   -0.05%     
==========================================
  Files         154      154              
  Lines       20216    20239      +23     
  Branches      462      461       -1     
==========================================
+ Hits        19600    19613      +13     
- Misses        511      520       +9     
- Partials      105      106       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@briansmith briansmith merged commit e3b7245 into main Dec 17, 2024
156 of 158 checks passed
@briansmith briansmith deleted the b/digest-infallible-1 branch December 17, 2024 00:38
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.

1 participant