jsonwebtoken icon indicating copy to clipboard operation
jsonwebtoken copied to clipboard

Improving allocation cost for Validation

Open elichai opened this issue 1 month ago • 1 comments

Hi :) It would be great if we could create a validation without allocating (and also paying for a HashSet when you only have 1/2 entries), as I have a bunch of issuers that I need to differentiate but I don't want to store a bunch of Validation objects and also some of their fields outisde (e.g. duplication across tid/issuer etc in azure) It would be great if we can enable reference based validation, this can be done via:

  1. A trait Validation (e.g with fn contains_issuer(issuer: &str) -> bool etc. with struct Validation implementing it, and downstream users may implement them however they want.
  2. Use some sort of enums inside Validation or provide a ValidationRef type

If this is something that is desired I can try to propose and implement the desired outcome

elichai avatar Nov 10 '25 13:11 elichai

The idea with Validation was really that you keep them around so it was not designed with that kind of optimization in mind. The trait approach would be better but I don't know if enough people want that to be worth doing

Keats avatar Nov 10 '25 20:11 Keats