der: add Reader::read_value
, auto-nest DecodeValue
#1877
Merged
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.
Previously
der
lacked an abstraction for automatically setting up nested readers when decoding values, so everyDecodeValue
impl ended up handling its own nesting.This adds a new provided method to the
Reader
trait which automatically handles nesting.This change is backwards compatible in that if a
DecodeValue
impl does its ownreader.read_nested
, it will just create another nested reader of the same length, which is redundant but doesn't break anything. However, we should remove all of theread_nested
calls fromDecodeValue
impls with this approach anyway as they're redundant.Using a provided method for this opens up the possibility of reader-specific handling of field decoding, which would be useful for addressing indefinite length handling for BER decoding (#779).