Currently, Choice automatically derives Decode.
But DecodeValue can be derived the same way.
For example, in x509-cert the following DecodeValue for DirectoryString is redundant.
|
impl<'a> der::DecodeValue<'a> for DirectoryString { |
|
type Error = der::Error; |
|
|
|
fn decode_value<R: Reader<'a>>(reader: &mut R, header: Header) -> Result<Self, Self::Error> { |
|
match header.tag { |
|
PrintableString::TAG => { |
|
PrintableString::decode_value(reader, header).map(Self::PrintableString) |
|
} |
|
TeletexString::TAG => { |
|
TeletexString::decode_value(reader, header).map(Self::TeletexString) |
|
} |
|
String::TAG => String::decode_value(reader, header).map(Self::Utf8String), |
|
actual => Err(der::ErrorKind::TagUnexpected { |
|
expected: None, |
|
actual, |
|
} |
|
.into()), |
|
} |
|
} |
|
} |
I think Decode should use DecodeValue in derive(Choice).
Currently, Choice automatically derives
Decode.But
DecodeValuecan be derived the same way.For example, in
x509-certthe followingDecodeValue for DirectoryStringis redundant.formats/x509-cert/src/ext/pkix/name/dirstr.rs
Lines 64 to 83 in 90b6617
I think
Decodeshould useDecodeValueinderive(Choice).