Skip to content
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

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

Open
Nicceboy opened this issue Oct 26, 2023 · 1 comment

Comments

@Nicceboy
Copy link
Contributor

Nicceboy commented Oct 26, 2023

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:

  • The performance impact if every character from the input stream is separately validated
  • Should the error type be Enum with variants of every string type or Struct (everyone separately)?
@XAMPPRocky
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants