Skip to content

der: better names for Decodable/DecodeValue/Encodable/EncodeValue #420

@tarcieri

Description

@tarcieri

The four main traits that comprise the decoding/encoding API have somewhat inconsistent names. To break them down along with their function:

Document / TLV decoding/encoding traits:

These traits also represent the main end user-facing API for those who wish to decode/encode DER documents:

  • Decodable
  • Encodable

Value decoding/encoding traits:

These traits are primarily used by ASN.1 format implementers, and are emitted by der_derive when using the Choice or Sequence macros:

  • DecodeValue
  • EncodeValue

Unlike Decodable/Encodable, these traits are specifically for parsing the "value" portion of a tag-length-value production, and they receive the TLV Header (tag/value) as an argument.

Having a separate trait for value decoding/encoding is important for implementing IMPLICIT context-specific productions, which may have arbitrary context-specific tags.

Problems

At the very least, the "-able" endings on Decodable and Encodable are inconsistent with the non-"able" endings used by DecodeValue/EncodeValue.

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