-
Notifications
You must be signed in to change notification settings - Fork 51
refactor: use TryFrom for Certificate and CertificateRecord conversions
#2652
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: use TryFrom for Certificate and CertificateRecord conversions
#2652
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the conversion between Certificate and CertificateRecord types by replacing infallible From trait implementations with fallible TryFrom trait implementations. This change makes error handling explicit for conversions that could potentially fail during serialization/deserialization operations.
- Replaced
Fromimplementations withTryFromforCertificate↔CertificateRecordconversions - Updated all call sites to use
try_into()with explicit error handling - Modified repository methods and test helpers to handle conversion errors properly
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
mithril-aggregator/src/database/record/certificate.rs |
Core implementation change from From to TryFrom for both conversion directions |
mithril-aggregator/src/database/repository/certificate_repository.rs |
Updated repository methods to handle fallible conversions with proper error propagation |
mithril-aggregator/src/database/test_helper.rs |
Modified test helper function to accept TryInto instead of Into |
mithril-aggregator/src/tools/certificates_hash_migrator.rs |
Updated test utility functions to use try_into().unwrap() |
mithril-aggregator/src/database/query/certificate/insert_certificate.rs |
Updated test code to use fallible conversions |
mithril-aggregator/src/database/query/certificate/insert_or_replace_certificate.rs |
Updated test code to use fallible conversions |
mithril-aggregator/src/database/query/certificate/get_certificate.rs |
Updated test code to use fallible conversions |
mithril-aggregator/src/database/query/certificate/insert_certificate.rs
Outdated
Show resolved
Hide resolved
mithril-aggregator/src/database/query/certificate/insert_or_replace_certificate.rs
Outdated
Show resolved
Hide resolved
c546db7 to
6226d17
Compare
Alenar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🐕
turmelclem
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🎸
…te conversions more idiomatic using `TryFrom`
0274f45 to
814b8b4
Compare
* mithril-aggregator from `0.7.76` to `0.7.77` * mithril-common from `0.6.11` to `0.6.12`
814b8b4 to
dc4c8a5
Compare
Content
This PR includes the replacement of
Fromimplementations with fallibleTryFromfor converting betweenCertificateandCertificateRecord.This PR includes...
Pre-submit checklist
Issue(s)
Closes #2651