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

der: Custom error types in derive macros. #1560

Merged
merged 6 commits into from
Oct 9, 2024

Conversation

turbocool3r
Copy link
Contributor

Add support for specifying a custom decode error type for Sequence, Enumerated and Choice derive macros using the #[asn1(error = Ty)] attribute.

This addresses #1559.

turbocool3r and others added 2 commits October 9, 2024 00:16
`Sequence`, `Enumerated` and `Choice` macros now support `#[asn1(error = Ty)]` attribute that provides a custom error type for `Decode`/`DecodeValue` implementations.

This addresses RustCrypto#1559.
Copy link
Member

@baloo baloo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks good, the only thing that comes to mind would be to use a type to hold the attribute instead.

I've made a PR of what I had in mind in turbocool3r#1.

But it's mostly up to you.

@turbocool3r
Copy link
Contributor Author

Thanks, just merged, that's a nice way to reduce that code duplication.

One last question is should the attribute be named something like decode_error_type to make its purpose more clear?

@baloo
Copy link
Member

baloo commented Oct 8, 2024

It's already asn1(error=...), I think it's good enough.

der_derive/src/enumerated.rs Outdated Show resolved Hide resolved
@baloo
Copy link
Member

baloo commented Oct 8, 2024

I can merge that later tonight and make an rc.1 release for it.

@turbocool3r
Copy link
Contributor Author

Merged the second PR, also added docs. I think it's ready for merge.

@baloo baloo merged commit 04313e4 into RustCrypto:master Oct 9, 2024
106 checks passed
@turbocool3r turbocool3r deleted the error-derive-attr branch October 9, 2024 17:34
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.

2 participants