Conversation
Codecov Report
@@ Coverage Diff @@
## main #170 +/- ##
==========================================
+ Coverage 72.14% 72.75% +0.60%
==========================================
Files 7 7
Lines 1881 1901 +20
==========================================
+ Hits 1357 1383 +26
+ Misses 524 518 -6
... and 1 file with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
djc
left a comment
There was a problem hiding this comment.
I'd squash these commits together. Maybe KeyPair::from_raw() should be called from_der(), too?
|
If what @djc said is implemented, this can be merged I think. |
|
(also needs a rebase) |
The `TryFrom` impl doesn't communicate that these bytes need to be DER-encoded. Forcing the user to use the constructor makes this obvious.
e57110c to
345bc9b
Compare
This more accurately describes what the function does.
Instead of chaining if-let-else constructs, we early return as soon as we successfully parse a keypair from the provided bytes. This is a tiny bit more code but easier to understand.
I've named it |
8182fbf to
3b61b11
Compare
3b61b11 to
e086f4a
Compare
|
I don't find all the refactoring very convincing because it still ends up with quite a bit of duplication. Would be happy to merge something closer to the original form though, I'd maybe rename |
Fair enough. I am surprised you mention duplication as the reason because the current version has less duplication than what is in
I went with |
By this logic shouldn't |
Yeah good thinking! Happy to change that if there is consensus on it :) |
It seems fine to me. Does anyone else have an opinion? I think it would be a good idea to take an action on this PR one way or the other. |
Not sure about others but I very often have a quick glance at the "first" layer of abstraction that I am calling from my code so in addition to there being value for contributors, I think there is also value for users. Arguably, not as much as the name of a public function of course.
I am open to either! There is also an open concern from @djc about whether the early-return style and separate functions are desirable. Should I revert those changes so we are just removing the |
| }) | ||
| } | ||
|
|
||
| fn pkcs_rsa_sha256(der: &[u8]) -> Result<KeyPair, Error> { |
There was a problem hiding this comment.
Could you remove these functions in favour of the old state which assigned kind? This saved us a lot of repetitive code.
|
I'm fine with the changes to the removal of |
|
Also probably needs a rebase once #183 is merged. |
|
Actually, I think maybe a cleaner route might be to introduce rustls-pki-types as a public dependency and use |
|
Closing as stale. Unfortunately, I don't have the resources to continue on this, sorry! |
|
Sorry that this one ended up sitting around for so long. Thanks for the contribution. |
The
TryFromimpl doesn't communicate that these bytes need to be DER-encoded. Forcing the user to use the constructor makes this obvious.This is a breaking change because it removes trait implementations.