der: add new
and derives to SequenceRef
#1980
Open
+10
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a reopening of #1977 which was closed because there was too little explaination. The motivation for adding the derives is that I cannot use
SequenceRef
in my structs that I want to output in the debug format or compare for equality.The motivation for creating new
SequenceRef
is a bit harder to explain: I have something like X.509ContentInfo
that needs raw data access. When decoding I need the buffer data to validate a signature and I need to add a raw buffer which I have signed when compiling the data. I also want to useder_derive
annotations to do all the validation for me.Up until recently I was using
AnyRef
for this purpose, but this broke in the recent0.8.0
release candidates (please see #1976 for more info). The thing is, instead of an explicit tag mode like inContentInfo
the format I am parsing is using the implicit tag mode and has theconstructed
bit set.AnyRef
does not work with this anymore and I can understand the reasoning.The next best thing we found in the linked case was (ab)using
SequenceRef
because it accepts having the implicit tag mode and the constructed bit set. And to be able to construct the type I need some kind of constructor forSequenceRef
.To be honest I would prefer having something that is more intentional for the purpose of raw data access, but still allows me to use the derive macro to specify the tag and tag mode implicit.
Tagging @dishmaker because we had a lengthy discussion in the linked case
Copying the example from the linked case. This used to work, but does not anymore: