Skip to content

Commit

Permalink
SubjectPublicKeyInfo -> SubjectPublicKeyInfoDer
Browse files Browse the repository at this point in the history
  • Loading branch information
cpu committed May 7, 2024
1 parent e5c3e1c commit 7184ef5
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,40 +502,40 @@ impl CertificateDer<'_> {

/// A DER-encoded SubjectPublicKeyInfo (SPKI), as specified in RFC 5280.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct SubjectPublicKeyInfo<'a>(Der<'a>);
pub struct SubjectPublicKeyInfoDer<'a>(Der<'a>);

impl AsRef<[u8]> for SubjectPublicKeyInfo<'_> {
impl AsRef<[u8]> for SubjectPublicKeyInfoDer<'_> {
fn as_ref(&self) -> &[u8] {
self.0.as_ref()
}
}

impl Deref for SubjectPublicKeyInfo<'_> {
impl Deref for SubjectPublicKeyInfoDer<'_> {
type Target = [u8];

fn deref(&self) -> &Self::Target {
self.as_ref()
}
}

impl<'a> From<&'a [u8]> for SubjectPublicKeyInfo<'a> {
impl<'a> From<&'a [u8]> for SubjectPublicKeyInfoDer<'a> {
fn from(slice: &'a [u8]) -> Self {
Self(Der::from(slice))
}
}

#[cfg(feature = "alloc")]
impl<'a> From<Vec<u8>> for SubjectPublicKeyInfo<'a> {
impl<'a> From<Vec<u8>> for SubjectPublicKeyInfoDer<'a> {
fn from(vec: Vec<u8>) -> Self {
Self(Der::from(vec))
}
}

impl SubjectPublicKeyInfo<'_> {
impl SubjectPublicKeyInfoDer<'_> {
/// Converts this SubjectPublicKeyInfo into its owned variant, unfreezing borrowed content (if any)
#[cfg(feature = "alloc")]
pub fn into_owned(self) -> SubjectPublicKeyInfo<'static> {
SubjectPublicKeyInfo(Der(self.0 .0.into_owned()))
pub fn into_owned(self) -> SubjectPublicKeyInfoDer<'static> {
SubjectPublicKeyInfoDer(Der(self.0 .0.into_owned()))
}
}

Expand Down

0 comments on commit 7184ef5

Please sign in to comment.