Skip to content

Commit

Permalink
Implement Deref[Mut] for Cipher on older OpenSSLs
Browse files Browse the repository at this point in the history
They don't do anything, but this can be useful when writing code that works with multiple versions of OpenSSL.
  • Loading branch information
alex committed Aug 5, 2023
1 parent b1ee513 commit 8449b82
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 8449b82

Please sign in to comment.