-
Notifications
You must be signed in to change notification settings - Fork 173
Description
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:
DecodableEncodable
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:
DecodeValueEncodeValue
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.