Skip to content

Conversation

@tarcieri
Copy link
Member

@tarcieri tarcieri commented Feb 1, 2022

Adds a type which wraps the value portion / "body" of a DER-serialized SEQUENCE.

This type subsumes the previous decoding logic for Decoder::sequence, parsing the SEQUENCE using DecodeValue and storing its position within the outer document.

In addition to simplifying the sequence decoding logic, this also makes it possible to use this type within the Sequence proc macro, which will allow it to impl DecodeValue. However, that work is left for a followup PR.

Adds a type which wraps the value portion / "body" of a DER-serialized
`SEQUENCE`.

This type subsumes the previous decoding logic for `Decoder::sequence`,
parsing the `SEQUENCE` using `DecodeValue` and storing its position
within the outer document.

In addition to simplifying the sequence decoding logic, this also makes
it possible to use this type within the `Sequence` proc macro, which
will allow it to impl `DecodeValue`. However, that work is left for a
followup PR.
/// Get the position within the buffer.
pub fn position(&self) -> Length {
self.position
// TODO(tarcieri): avoid potential panic here
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can probably be addressed by incrementing both position and offset when data is read. This was a quick workaround to get everything initially working.

@tarcieri tarcieri merged commit 8985b92 into master Feb 1, 2022
@tarcieri tarcieri deleted the der/sequenceref branch February 1, 2022 16:50
tarcieri added a commit that referenced this pull request Feb 1, 2022
The proc macro previously derived the `Decode` trait, which is not
composable with context-specific fields, which depend on the
`DecodeValue` trait in order to support IMPLICIT fields.

This commit changes the custom derive macro for `Sequence` to produce
a `DecodeValue` impl instead of `Decode`. This leverages the newly
introduced `SequenceRef` type from #374.
tarcieri added a commit that referenced this pull request Feb 1, 2022
The proc macro previously derived the `Decode` trait, which is not
composable with context-specific fields, which depend on the
`DecodeValue` trait in order to support IMPLICIT fields.

This commit changes the custom derive macro for `Sequence` to produce
a `DecodeValue` impl instead of `Decode`. This leverages the newly
introduced `SequenceRef` type from #374.
@tarcieri tarcieri mentioned this pull request May 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants