-
Notifications
You must be signed in to change notification settings - Fork 173
Closed
Description
This is related to #410.
The crate could use the Integer proc macro, if pkcs8's Version enum get's a repr attribute.
This would remove this duplicate code:
pkcs1
Lines 54 to 72 in 9ac5281
| impl Decodable<'_> for Version { | |
| fn decode(decoder: &mut Decoder<'_>) -> der::Result<Self> { | |
| Version::try_from(u8::decode(decoder)?).map_err(|_| Self::TAG.value_error()) | |
| } | |
| } | |
| impl Encodable for Version { | |
| fn encoded_len(&self) -> der::Result<der::Length> { | |
| der::Length::ONE.for_tlv() | |
| } | |
| fn encode(&self, encoder: &mut Encoder<'_>) -> der::Result<()> { | |
| u8::from(*self).encode(encoder) | |
| } | |
| } | |
| impl FixedTag for Version { | |
| const TAG: Tag = Tag::Integer; | |
| } |
pkcs8
Lines 28 to 42 in 9ac5281
| impl Decodable<'_> for Version { | |
| fn decode(decoder: &mut Decoder<'_>) -> der::Result<Self> { | |
| Version::try_from(u8::decode(decoder)?).map_err(|_| Self::TAG.value_error()) | |
| } | |
| } | |
| impl Encodable for Version { | |
| fn encoded_len(&self) -> der::Result<der::Length> { | |
| der::Length::from(1u8).for_tlv() | |
| } | |
| fn encode(&self, encoder: &mut Encoder<'_>) -> der::Result<()> { | |
| u8::from(*self).encode(encoder) | |
| } | |
| } |
Lines 61 to 63 in 9ac5281
| impl FixedTag for Version { | |
| const TAG: Tag = Tag::Integer; | |
| } |
Metadata
Metadata
Assignees
Labels
No labels