Skip to content

der: extract a Decoder type in next breaking release #2533

Open

Description

@tarcieri

der used to have a Decoder type, but it was refactored into SliceReader. Logic for handling nested productions winds up duplicated among the various *Reader impls in their Reader::read_nested methods, which are custom implemented per Reader type.

In ssh-encoding, which uses a similar arrangement of types, I introduced a Decoder type generic over a backend Reader which handles the central logic for consuming data from the readers, and all of the Decode methods now accept a &mut Decoder<impl Reader>: RustCrypto/SSH#618

In the next breaking release of der I think it'd be nice to do something similar. I added some partial shared logic in the Position type, but really it'd be nice to eliminate the duplication of logic between the reader types.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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