1
1
//! SSL/TLS support.
2
2
//!
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
4
4
//! configuration of the OpenSSL primitives for you.
5
5
//!
6
6
//! # Examples
70
70
//! }
71
71
//! }
72
72
//! ```
73
+ use ffi;
73
74
use libc:: { c_int, c_void, c_long, c_ulong} ;
75
+ use libc:: { c_uchar, c_uint} ;
74
76
use std:: any:: Any ;
75
77
use std:: any:: TypeId ;
76
78
use std:: cmp;
@@ -79,15 +81,14 @@ use std::ffi::{CStr, CString};
79
81
use std:: fmt;
80
82
use std:: io;
81
83
use std:: io:: prelude:: * ;
84
+ use std:: marker:: PhantomData ;
82
85
use std:: mem;
86
+ use std:: ops:: { Deref , DerefMut } ;
83
87
use std:: path:: Path ;
84
88
use std:: ptr;
89
+ use std:: slice;
85
90
use std:: str;
86
91
use std:: sync:: Mutex ;
87
- use libc:: { c_uchar, c_uint} ;
88
- use std:: slice;
89
- use std:: marker:: PhantomData ;
90
- use ffi;
91
92
92
93
use { init, cvt, cvt_p} ;
93
94
use dh:: DhRef ;
@@ -781,6 +782,20 @@ impl OpenSslType for SslCipher {
781
782
}
782
783
}
783
784
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
+
784
799
pub struct SslCipherRef ( Opaque ) ;
785
800
786
801
impl OpenSslTypeRef for SslCipherRef {
@@ -789,7 +804,7 @@ impl OpenSslTypeRef for SslCipherRef {
789
804
790
805
impl SslCipherRef {
791
806
/// Returns the name of cipher.
792
- pub fn name ( & self ) -> & ' static str {
807
+ pub fn name ( & self ) -> & str {
793
808
let name = unsafe {
794
809
let ptr = ffi:: SSL_CIPHER_get_name ( self . as_ptr ( ) ) ;
795
810
CStr :: from_ptr ( ptr as * const _ )
@@ -799,7 +814,7 @@ impl SslCipherRef {
799
814
}
800
815
801
816
/// Returns the SSL/TLS protocol version that first defined the cipher.
802
- pub fn version ( & self ) -> & ' static str {
817
+ pub fn version ( & self ) -> & str {
803
818
let version = unsafe {
804
819
let ptr = ffi:: SSL_CIPHER_get_version ( self . as_ptr ( ) ) ;
805
820
CStr :: from_ptr ( ptr as * const _ )
0 commit comments