Skip to content

Commit

Permalink
Merge pull request #2008 from alex/deref-cipher
Browse files Browse the repository at this point in the history
Implement Deref[Mut] for Cipher on older OpenSSLs
  • Loading branch information
alex authored Aug 5, 2023
2 parents b1ee513 + 8449b82 commit 0008d12
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion openssl/src/cipher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use foreign_types::{ForeignTypeRef, Opaque};
use openssl_macros::corresponds;
#[cfg(ossl300)]
use std::ffi::CString;
use std::ops::{Deref, DerefMut};
#[cfg(ossl300)]
use std::ptr;

Expand Down Expand Up @@ -41,7 +42,6 @@ cfg_if! {
cfg_if! {
if #[cfg(ossl300)] {
use foreign_types::ForeignType;
use std::ops::{Deref, DerefMut};

type Inner = *mut ffi::EVP_CIPHER;

Expand Down Expand Up @@ -90,6 +90,22 @@ cfg_if! {
}
} else {
enum Inner {}

impl Deref for Cipher {
type Target = CipherRef;

#[inline]
fn deref(&self) -> &Self::Target {
match self.0 {}
}
}

impl DerefMut for Cipher {
#[inline]
fn deref_mut(&mut self) -> &mut Self::Target {
match self.0 {}
}
}
}
}

Expand Down

0 comments on commit 0008d12

Please sign in to comment.