der-parser icon indicating copy to clipboard operation
der-parser copied to clipboard

Make the Header lifetime more readable

Open honsunrise opened this issue 3 years ago • 1 comments

honsunrise avatar May 03 '22 10:05 honsunrise

Hi,

Thank you for the PR. However, I'm not sure setting the Header lifetime to the input's is required: in those functions, the header is only used, not stored, so there are situations where the header could live less time than the input.

I think that if you want to clarify the lifetime, then adding an explicit second lifetime (for ex 'hdr), different from 'a, would be the correct way.

chifflier avatar May 24 '22 09:05 chifflier

If you look at the CI annotation (failure in doc tests at src/der/parser.rs#L335), you'll see the lifetime problem explained above in parse_der_implicit, parse_ber_implicit and others: the Header would now be forced to have the lifetime of the input bytes.

Now, I do not think the solution is to tie the lifetimes together, there is no real reason to do so, and it add constraints to the input.

chifflier avatar Mar 07 '23 09:03 chifflier