Skip to content

INTEGER as C-like enums ( or enums with discriminators) #40

Answered by XAMPPRocky
naveedpash asked this question in Q&A
Discussion options

You must be logged in to vote

Thank you for your question. Yeah this falls under #6 as providing constraints for integers, which isn't supported directly at the moment.

For this specific instance though, you should be able to model pretty well in rasn by using enumerated and setting #[rasn(tag(universal, 2)], which would encode it as an integer but also check if it matches any of the variants. It's a bit hacky, but if you don't want to write the validation it should work.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@naveedpash
Comment options

Answer selected by naveedpash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants