Skip to content

Commit

Permalink
experiment
Browse files Browse the repository at this point in the history
  • Loading branch information
reaperhulk committed Sep 1, 2024
1 parent d6dfbd2 commit 3a7b7c3
Showing 1 changed file with 24 additions and 26 deletions.
50 changes: 24 additions & 26 deletions openssl/src/md.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,32 +31,6 @@ cfg_if! {
}
}

impl ForeignType for Md {
type CType = ffi::EVP_MD;
type Ref = MdRef;

#[inline]
unsafe fn from_ptr(ptr: *mut Self::CType) -> Self {
Md(ptr)
}

#[inline]
fn as_ptr(&self) -> *mut Self::CType {
self.0
}
}

impl Deref for Md {
type Target = MdRef;

#[inline]
fn deref(&self) -> &Self::Target {
unsafe {
MdRef::from_ptr(self.as_ptr())
}
}
}

impl DerefMut for Md {
#[inline]
fn deref_mut(&mut self) -> &mut Self::Target {
Expand All @@ -70,6 +44,30 @@ cfg_if! {
}
}

impl ForeignType for Md {
type CType = ffi::EVP_MD;
type Ref = MdRef;

#[inline]
unsafe fn from_ptr(ptr: *mut Self::CType) -> Self {
Md(ptr)
}

#[inline]
fn as_ptr(&self) -> *mut Self::CType {
self.0
}
}

impl Deref for Md {
type Target = MdRef;

#[inline]
fn deref(&self) -> &Self::Target {
unsafe { MdRef::from_ptr(self.as_ptr()) }
}
}

/// A message digest algorithm.
pub struct Md(Inner);

Expand Down

0 comments on commit 3a7b7c3

Please sign in to comment.