Skip to content

der: add IsConstructed trait #1741

@dishmaker

Description

@dishmaker

IMPLICIT decoder requires Tagged trait.

pub fn decode_implicit<'a, R: Reader<'a>>(
reader: &mut R,
tag_number: TagNumber,
) -> Result<Option<Self>, T::Error>
where
T: DecodeValue<'a> + Tagged,

IMPLICIT and EXPLICIT decoders check for constructed bit.
But IMPLICIT depends on value.tag() in runtime:

if header.tag.is_constructed() != value.tag().is_constructed() {
return Err(header.tag.non_canonical_error().into());

fn tag(&self) -> Tag {
let constructed = match self.tag_mode {
TagMode::Explicit => true,
TagMode::Implicit => self.value.tag().is_constructed(),

I think it should check constructed bit statically, like FixedTag.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions