Skip to content

Commit 1985c7f

Browse files
authored
der_derive: remove OctetStringRefDeriveHack (#2043)
Fixes #2039
1 parent 4db4c09 commit 1985c7f

File tree

4 files changed

+7
-15
lines changed

4 files changed

+7
-15
lines changed

der/src/asn1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub use self::{
4444
ia5_string::Ia5StringRef,
4545
integer::{int::IntRef, uint::UintRef},
4646
null::Null,
47-
octet_string::{OctetStringRef, OctetStringRefDeriveHack},
47+
octet_string::OctetStringRef,
4848
printable_string::PrintableStringRef,
4949
private::{Private, PrivateRef},
5050
sequence::{Sequence, SequenceRef},

der/src/asn1/octet_string.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,6 @@ use crate::{
55
Tag, Writer, asn1::AnyRef, ord::OrdIsValueOrd,
66
};
77

8-
/// Custom derive hack until `der_derive` is updated to support `&'a MyRef` reference types.
9-
///
10-
/// This is not considered a stable part of the public API and may be removed without warning.
11-
// TODO(tarcieri): update `der_derive` to support `OctetStringRef` properly. See #2039
12-
#[doc(hidden)]
13-
pub type OctetStringRefDeriveHack<'a> = &'a OctetStringRef;
14-
158
/// ASN.1 `OCTET STRING` type: borrowed form.
169
///
1710
/// Octet strings represent contiguous sequences of octets, a.k.a. bytes.

der_derive/src/asn1_type.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl Asn1Type {
5959
/// Get a `der::Decoder` object for a particular ASN.1 type
6060
pub fn decoder(self) -> TokenStream {
6161
let type_path = self.type_path();
62-
quote!(#type_path::decode(reader)?)
62+
quote!(<#type_path>::decode(reader)?)
6363
}
6464

6565
/// Get a `der::Decoder` optional object for a particular ASN.1 type
@@ -71,7 +71,7 @@ impl Asn1Type {
7171
/// Get a `der::DecodeValue` member object for a particular ASN.1 type
7272
pub fn value_decoder(self) -> TokenStream {
7373
let type_path = self.type_path();
74-
quote!(#type_path::decode_value(reader, header)?)
74+
quote!(<#type_path>::decode_value(reader, header)?)
7575
}
7676

7777
/// Get a `der::DecodeValue` member object for a particular ASN.1 type
@@ -83,7 +83,7 @@ impl Asn1Type {
8383
/// Get a `der::Encoder` object for a particular ASN.1 type
8484
pub fn encoder(self, binding: &TokenStream) -> TokenStream {
8585
let type_path = self.type_path();
86-
quote!(#type_path::try_from(#binding)?)
86+
quote!(<#type_path>::try_from(#binding)?)
8787
}
8888

8989
/// Get the Rust type path for a particular ASN.1 type.
@@ -93,8 +93,7 @@ impl Asn1Type {
9393
Asn1Type::BitString => quote!(::der::asn1::BitStringRef),
9494
Asn1Type::Ia5String => quote!(::der::asn1::Ia5StringRef),
9595
Asn1Type::GeneralizedTime => quote!(::der::asn1::GeneralizedTime),
96-
// TODO(tarcieri): natively support `OctetStringRef`, remove `OctetStringRefDeriveHack`
97-
Asn1Type::OctetString => quote!(::der::asn1::OctetStringRefDeriveHack),
96+
Asn1Type::OctetString => quote!(&::der::asn1::OctetStringRef),
9897
Asn1Type::PrintableString => quote!(::der::asn1::PrintableStringRef),
9998
Asn1Type::TeletexString => quote!(::der::asn1::TeletexStringRef),
10099
Asn1Type::VideotexString => quote!(::der::asn1::VideotexStringRef),

der_derive/src/choice/variant.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ mod tests {
250250
variant.to_decode_tokens().to_string(),
251251
quote! {
252252
::der::Tag::Utf8String => Ok(Self::ExampleVariant(
253-
::der::asn1::Utf8StringRef::decode(reader)?
253+
<::der::asn1::Utf8StringRef>::decode(reader)?
254254
.try_into()?
255255
)),
256256
}
@@ -260,7 +260,7 @@ mod tests {
260260
assert_eq!(
261261
variant.to_encode_value_tokens().to_string(),
262262
quote! {
263-
Self::ExampleVariant(variant) => ::der::asn1::Utf8StringRef::try_from(variant)?.encode_value(encoder),
263+
Self::ExampleVariant(variant) => <::der::asn1::Utf8StringRef>::try_from(variant)?.encode_value(encoder),
264264
}
265265
.to_string()
266266
);

0 commit comments

Comments
 (0)