Closed shahn closed 3 months ago
Thank you for your issue. As I understand it, the feature would rather be part of rasn
itself than the compiler. Please feel free to open an issue here. That said, I guess the constraint checker would run pretty much the same logic under the hood as the encode
function, so you could just call encode and check the Err
of the returned Result
. Let us know though, if there is something missing in the error reporting of the encoder.
I think the error reporting is fine, the idea was just to use the types generated by rasn-compiler as "definitely valid, encoding won't fail" types. Your reasoning is totally understandable though, thanks for providing your rationale. 👍
Would there be interest in deriving a function which checks the constraints when constructing an
AsnType
, such asnew_with_constraints() -> Result <_, ConstraintError>
? That would allow users to ensure they are not operating with invalid values in their application logic before calling encode.