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

Add custom error types to the Decode and DecodeValue traits. #1055

Merged
merged 1 commit into from
Mar 2, 2024

Conversation

turbocool3r
Copy link
Contributor

Adds support for specifying custom error types for the Encode, Decode, EncodeValue, DecodeValue, DerOrd and ValueOrd traits (see #1053).

@tarcieri
Copy link
Member

tarcieri commented May 8, 2023

Just to set expectations: it will probably be a few months before we're ready to start making breaking changes again

der/src/ord.rs Outdated Show resolved Hide resolved
@turbocool3r
Copy link
Contributor Author

Just to set expectations: it will probably be a few months before we're ready to start making breaking changes again

That's ok, I'll leave this PR in place until it can be accepted.

@turbocool3r turbocool3r changed the title Add custom error types to the Encode/Decode and (Der|Value)Ord traits. Add custom error types to the Decode and DecodeValue traits. May 8, 2023
@tarcieri
Copy link
Member

tarcieri commented Jan 21, 2024

It's possible to make breaking changes now.

However, I've opened #1328 which provides a less invasive alternative: it allows der::Error to carry with it an arbitrary error source when the std feature is enabled. It's not perfect but at least provides a stopgap solution.

That said, I think this approach is still interesting, and closer to e.g. what serde does.

@tarcieri
Copy link
Member

tarcieri commented Jan 22, 2024

@turbocool3r if you can get this PR green we can consider it over #1328.

@turbocool3r
Copy link
Contributor Author

Ok, I'll try to do this by Wednesday

@turbocool3r turbocool3r force-pushed the custom-errors branch 7 times, most recently from 1ff2bf5 to 5638fc3 Compare January 23, 2024 21:13
@turbocool3r
Copy link
Contributor Author

It seems this won't be completely green because there are some dependencies on external crates like signature which should be modified separately.

There also was an issue with the DecodePem trait: adding a generic error type there causes the from_pem method to fail the borrow check even if both T and Error are marked as 'static. Forcing the error to be der::Error there fixes the issue.

@tarcieri
Copy link
Member

It seems this won't be completely green because there are some dependencies on external crates like signature which should be modified separately.

Err, how so?

@turbocool3r
Copy link
Contributor Author

@tarcieri
Copy link
Member

Aah, in ecdsa. I can open a PR for that if you'd like.

@turbocool3r
Copy link
Contributor Author

Aah, in ecdsa. I can open a PR for that if you'd like.

It would be nice. I think we need to first get this as it goes to see the complete list of crates that need to be modified.

@turbocool3r
Copy link
Contributor Author

Yes, it seems it's only ecdsa, not signature.

@turbocool3r turbocool3r marked this pull request as ready for review January 23, 2024 21:45
@turbocool3r
Copy link
Contributor Author

Hey, how about that pull request? I could probably do that myself to save some time.

@tarcieri
Copy link
Member

Sorry, I've been meaning to get to it and I'd love to land this, but if you'd like to go for it that works too.

It's going to be oddly circular so you need to make a PR to https://github.com/rustcrypto/formats which uses a [patch.crates-io] directive to point to this branch, then you'll need to reference the branch in this PR to complete the cycle.

@turbocool3r
Copy link
Contributor Author

Did you mean the https://github.com/RustCrypto/signatures repo? By this branch do you mean my fork or some other branch?

@tarcieri
Copy link
Member

Err sorry, yes https://github.com/RustCrypto/signatures

You'll need to point to your branch on your fork for both this repo when updating signatures and again in a circular manner in your fork of signatures to update this PR

turbocool3r added a commit to turbocool3r/signatures that referenced this pull request Feb 14, 2024
Goes in pair with [this](RustCrypto/formats#1055) PR to `formats`.
@turbocool3r
Copy link
Contributor Author

Seems all green now, the signatures PR is RustCrypto/signatures#809.

@tarcieri
Copy link
Member

Thanks, will review and try to get this merged ASAP

@turbocool3r
Copy link
Contributor Author

Thanks!

Cargo.toml Outdated Show resolved Hide resolved
@tarcieri tarcieri merged commit c501837 into RustCrypto:master Mar 2, 2024
165 checks passed
@turbocool3r turbocool3r deleted the custom-errors branch March 3, 2024 07:28
@turbocool3r turbocool3r restored the custom-errors branch March 3, 2024 16:26
turbocool3r added a commit to turbocool3r/signatures that referenced this pull request Mar 3, 2024
Goes in pair with [this](RustCrypto/formats#1055) PR to `formats`.
tarcieri pushed a commit to RustCrypto/signatures that referenced this pull request Mar 3, 2024
@turbocool3r turbocool3r deleted the custom-errors branch March 6, 2024 17:29
tarcieri added a commit that referenced this pull request Mar 28, 2024
This reverts commit 7784f2d.

This ended up complicating downstream error types, particularly in
`no_std` contexts.

It's also not really necessary now that #1055 has landed.
tarcieri added a commit that referenced this pull request Mar 28, 2024
…" (#1371)

This reverts commit 7784f2d.

This ended up complicating downstream error types, particularly in
`no_std` contexts.

It's also not really necessary now that #1055 has landed.
baloo added a commit to baloo/formats that referenced this pull request Mar 28, 2024
baloo added a commit that referenced this pull request Mar 28, 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.

3 participants