Skip to content

Commit 79e2004

Browse files
committed
Fixes
1 parent 8ad1e55 commit 79e2004

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

openssl/src/ssl/mod.rs

+22-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! SSL/TLS support.
22
//!
3-
//! The `SslConnector` and `SslAcceptor` should be used in most cases - they handle
3+
//! `SslConnector` and `SslAcceptor` should be used in most cases - they handle
44
//! configuration of the OpenSSL primitives for you.
55
//!
66
//! # Examples
@@ -70,7 +70,9 @@
7070
//! }
7171
//! }
7272
//! ```
73+
use ffi;
7374
use libc::{c_int, c_void, c_long, c_ulong};
75+
use libc::{c_uchar, c_uint};
7476
use std::any::Any;
7577
use std::any::TypeId;
7678
use std::cmp;
@@ -79,15 +81,14 @@ use std::ffi::{CStr, CString};
7981
use std::fmt;
8082
use std::io;
8183
use std::io::prelude::*;
84+
use std::marker::PhantomData;
8285
use std::mem;
86+
use std::ops::{Deref, DerefMut};
8387
use std::path::Path;
8488
use std::ptr;
89+
use std::slice;
8590
use std::str;
8691
use std::sync::Mutex;
87-
use libc::{c_uchar, c_uint};
88-
use std::slice;
89-
use std::marker::PhantomData;
90-
use ffi;
9192

9293
use {init, cvt, cvt_p};
9394
use dh::DhRef;
@@ -781,6 +782,20 @@ impl OpenSslType for SslCipher {
781782
}
782783
}
783784

785+
impl Deref for SslCipher {
786+
type Target = SslCipherRef;
787+
788+
fn deref(&self) -> &SslCipherRef {
789+
unsafe { SslCipherRef::from_ptr(self.0) }
790+
}
791+
}
792+
793+
impl DerefMut for SslCipher {
794+
fn deref_mut(&mut self) -> &mut SslCipherRef {
795+
unsafe { SslCipherRef::from_ptr_mut(self.0) }
796+
}
797+
}
798+
784799
pub struct SslCipherRef(Opaque);
785800

786801
impl OpenSslTypeRef for SslCipherRef {
@@ -789,7 +804,7 @@ impl OpenSslTypeRef for SslCipherRef {
789804

790805
impl SslCipherRef {
791806
/// Returns the name of cipher.
792-
pub fn name(&self) -> &'static str {
807+
pub fn name(&self) -> &str {
793808
let name = unsafe {
794809
let ptr = ffi::SSL_CIPHER_get_name(self.as_ptr());
795810
CStr::from_ptr(ptr as *const _)
@@ -799,7 +814,7 @@ impl SslCipherRef {
799814
}
800815

801816
/// Returns the SSL/TLS protocol version that first defined the cipher.
802-
pub fn version(&self) -> &'static str {
817+
pub fn version(&self) -> &str {
803818
let version = unsafe {
804819
let ptr = ffi::SSL_CIPHER_get_version(self.as_ptr());
805820
CStr::from_ptr(ptr as *const _)

0 commit comments

Comments
 (0)