librasn / rasn

A Safe #[no_std] ASN.1 Codec Framework
Other
183 stars 43 forks source link

Change the decoding behaviour for restricted string types to raise error when invalid character occured #185

Open Nicceboy opened 8 months ago

Nicceboy commented 8 months ago

Currently the decoding behaviour for restricted string types is, that on debug build, invalid character will cause panic. On release builds they are ignored, and there is no error.

There was some discussion that this should be changed, so leaving this issue as reminder.

Few things to consider:

XAMPPRocky commented 8 months ago

The performance impact if every character from the input stream is separately validated

I think if this is a concern we could probably look at SIMD or aho-corasick for performing the validation, those should be quick on large strings.

Should the error type be Enum with variants of every string type or Struct (everyone separately)?

I think a struct so that we can implement try_from and similar traits with the string's specific error.