-
Notifications
You must be signed in to change notification settings - Fork 1.7k
asn1: Add support for IMPLICIT and EXPLICIT
#13735
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Facundo Tuesca <[email protected]>
54a0c20 to
0a47aaa
Compare
Signed-off-by: Facundo Tuesca <[email protected]>
30fc662 to
4b76630
Compare
| encoding = None | ||
| for raw_annotation in metadata: | ||
| if isinstance(raw_annotation, Default): | ||
| default = raw_annotation.value | ||
| elif isinstance(raw_annotation, Explicit): | ||
| encoding = declarative_asn1.Encoding.Explicit(raw_annotation.tag) | ||
| elif isinstance(raw_annotation, Implicit): | ||
| encoding = declarative_asn1.Encoding.Implicit(raw_annotation.tag) |
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.
You need to prohibit duplicates (I guess this is true of defaults as well!)
| value: U | ||
|
|
||
|
|
||
| @dataclasses.dataclass(frozen=True) |
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.
Do we need these, or could we expose Encoding.Explicit and Encoding.Implicit as these types?
| // Since for optional types the annotations are enforced to be associated with the Option | ||
| // (instead of the inner type), when decoding the inner type we add the annotations of the Option |
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.
I'm not sure I follow.
| Encoding::Implicit(n) => asn1::implicit_tag(*n, inner_tag), | ||
| Encoding::Explicit(n) => asn1::explicit_tag(*n), |
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.
These are currenyly #[doc(hidden)] and thus not part of the stable API. We need to either change that, or represent these a different way.
|
@facutuesca Just a friendly ping since we're probably only a few weeks away from 47.0.0. If we need to slip to 48 that's fine of course. |
This PR adds support for
IMPLICITandEXPLICITfields to the ASN.1 API. The field types must be annotated withasn1.Implicit(tag=X)orasn1.Explicit(tag=Y):Part of #12283