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

refactor: make clone_public_key infallible #365

Closed

Conversation

nicmr
Copy link
Contributor

@nicmr nicmr commented Oct 21, 2024

Hi, I was wondering why KeyPair::clone_public_key was fallible.
Turns out only the RsaPrivate -> RsaPublic conversion used TryFrom internally - a TryFrom implementation that never failed and just returned Ok, so it could just be From.
I've switched out TryFrom for From and switched the Result type for clone_public_key from Result<T> to T.

I've updated the tests and doctests touching clone_public_key to use the new signature so they all compile and pass again.

The only argument I see right now not to change the signature would be for forward compatibility for key types where there actually is a sensible error scenario for extracting the public key, which I find hard to imagine. Please let me know if I'm being ignorant here 🤔

Best Regards

@nicmr
Copy link
Contributor Author

nicmr commented Oct 21, 2024

taking a look at the compile error

@nicmr
Copy link
Contributor Author

nicmr commented Oct 21, 2024

Sorry, I totally missed to check with the openSSL backend, which is why this has to be fallible, and I only use the pure rust implementation locally. At least I understand the reason now. 🤦

@nicmr nicmr closed this Oct 21, 2024
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