rusticata / der-parser

BER/DER parser written in pure Rust. Fast, zero-copy, safe.
Apache License 2.0
84 stars 29 forks source link

Make the Header lifetime more readable #63

Closed honsunrise closed 1 year ago

chifflier commented 2 years ago

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 commented 1 year ago

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.