diff --git a/der/src/asn1/bit_string.rs b/der/src/asn1/bit_string.rs index a6472f396..5ca56f4a9 100644 --- a/der/src/asn1/bit_string.rs +++ b/der/src/asn1/bit_string.rs @@ -256,11 +256,11 @@ impl FixedTag for BitStringRef<'_> { /// contains unused bits prefix and therefore cannot be a simple `&'a BitStringRef` slice. pub trait AsBitStringRef { /// Borrows the owned or ref `BIT STRING` as [`BitStringRef`] - fn as_bit_string(&self) -> BitStringRef<'_>; + fn as_bit_string_ref(&self) -> BitStringRef<'_>; } impl AsBitStringRef for BitStringRef<'_> { - fn as_bit_string(&self) -> BitStringRef<'_> { + fn as_bit_string_ref(&self) -> BitStringRef<'_> { *self } } @@ -576,7 +576,7 @@ mod allocating { } impl AsBitStringRef for BitString { - fn as_bit_string(&self) -> BitStringRef<'_> { + fn as_bit_string_ref(&self) -> BitStringRef<'_> { BitStringRef::from(self) } } diff --git a/pkcs8/src/private_key_info.rs b/pkcs8/src/private_key_info.rs index 6ab7c4a7b..421aa846b 100644 --- a/pkcs8/src/private_key_info.rs +++ b/pkcs8/src/private_key_info.rs @@ -5,7 +5,7 @@ use core::fmt; use der::{ Decode, DecodeValue, Encode, EncodeValue, FixedTag, Header, Length, Reader, Sequence, TagMode, TagNumber, Writer, - asn1::{AnyRef, BitStringRef, ContextSpecific, OctetStringRef, SequenceRef}, + asn1::{AnyRef, AsBitStringRef, BitStringRef, ContextSpecific, OctetStringRef, SequenceRef}, }; use spki::AlgorithmIdentifier; @@ -159,6 +159,7 @@ impl PrivateKeyInfo { } } +#[allow(deprecated)] impl<'a, Params, Key, PubKey> PrivateKeyInfo where Params: der::Choice<'a, Error = der::Error> + Encode, @@ -219,6 +220,7 @@ where } } +#[allow(deprecated)] impl<'a, Params, Key, PubKey> PrivateKeyInfo where Params: der::Choice<'a> + Encode, @@ -279,6 +281,7 @@ where } } +#[allow(deprecated)] impl<'a, Params, Key, PubKey> EncodeValue for PrivateKeyInfo where Params: der::Choice<'a, Error = der::Error> + Encode, @@ -301,6 +304,7 @@ where } } +#[allow(deprecated)] impl<'a, Params, Key, PubKey> Sequence<'a> for PrivateKeyInfo where Params: der::Choice<'a, Error = der::Error> + Encode, @@ -311,6 +315,7 @@ where { } +#[allow(deprecated)] impl<'a, Params, Key, PubKey> TryFrom<&'a [u8]> for PrivateKeyInfo where Params: der::Choice<'a, Error = der::Error> + Encode, @@ -341,6 +346,7 @@ where } #[cfg(feature = "alloc")] +#[allow(deprecated)] impl<'a, Params, Key, PubKey> TryFrom> for SecretDocument where Params: der::Choice<'a, Error = der::Error> + Encode, @@ -357,6 +363,7 @@ where } #[cfg(feature = "alloc")] +#[allow(deprecated)] impl<'a, Params, Key, PubKey> TryFrom<&PrivateKeyInfo> for SecretDocument where Params: der::Choice<'a, Error = der::Error> + Encode, @@ -444,15 +451,20 @@ pub type PrivateKeyInfoRef<'a> = PrivateKeyInfo, &'a OctetStringRef, /// [`BitStringLike`] marks object that will act like a `BitString`. /// -/// It will allow to get a [`BitStringRef`] that points back to the underlying bytes. -// TODO(tarcieri): replace this with `AsRef` when we can have `&BitStringRef`. +/// Note: this trait was replaced by [`AsBitStringRef`] +#[deprecated(since = "0.11.1", note = "Use `AsBitStringRef` instead")] +// TODO: replace this with `der::asn1::AsBitStringRef` pub trait BitStringLike { fn as_bit_string(&self) -> BitStringRef<'_>; } -impl BitStringLike for BitStringRef<'_> { +#[allow(deprecated)] +impl BitStringLike for T +where + T: AsBitStringRef, +{ fn as_bit_string(&self) -> BitStringRef<'_> { - BitStringRef::from(self) + self.as_bit_string_ref() } } @@ -546,10 +558,4 @@ pub(crate) mod allocating { } } } - - impl BitStringLike for BitString { - fn as_bit_string(&self) -> BitStringRef<'_> { - BitStringRef::from(self) - } - } }