-
Notifications
You must be signed in to change notification settings - Fork 1.7k
asn1: Add support for SIZE to SEQUENCE OF
#13899
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
Conversation
Signed-off-by: Facundo Tuesca <[email protected]>
5fb6bde to
d8f766e
Compare
alex
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.
we should block size annotations with types we don't do anything with them
| min: int | ||
| max: int | None | ||
|
|
||
| def __new__(cls, min: int, max: int | None) -> Size: ... |
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 guess if you want no min you just do min=0?
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.
yup
| let list_len = list.len(); | ||
| let min = size.get().min; | ||
| let max = size.get().max.unwrap_or(usize::MAX); | ||
| if list_len < min || list_len > max { |
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 think this is like, 2% easier to read as if !(min..=max).contains(&list_len) since thats it unavoidable that it's an inclusive range
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.
fixed
| if let Some(size) = &annotated_type.annotation.get().size { | ||
| let min = size.get().min; | ||
| let max = size.get().max.unwrap_or(usize::MAX); | ||
| if values.len() < min || values.len() > max { |
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.
Same
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.
fixed
Signed-off-by: Facundo Tuesca <[email protected]>
done! |
This PR adds support for
SIZEannotations to the ASN.1 API, starting with fields of typeSEQUENCE OF.Part of #12283