aboutsummaryrefslogtreecommitdiff
path: root/openssl
diff options
context:
space:
mode:
authorSteven Fackler <[email protected]>2016-11-05 19:28:17 -0700
committerSteven Fackler <[email protected]>2016-11-05 19:28:17 -0700
commit79e2004eefcb129a03f1f6b8db34af07ed212dd8 (patch)
tree92873a4a6bcc8892401a1cdf46a1f47a0c7173f2 /openssl
parentRemove set_rsa (diff)
downloadrust-openssl-79e2004eefcb129a03f1f6b8db34af07ed212dd8.tar.xz
rust-openssl-79e2004eefcb129a03f1f6b8db34af07ed212dd8.zip
Fixes
Diffstat (limited to 'openssl')
-rw-r--r--openssl/src/ssl/mod.rs29
1 files changed, 22 insertions, 7 deletions
diff --git a/openssl/src/ssl/mod.rs b/openssl/src/ssl/mod.rs
index 85186e28..9a477993 100644
--- a/openssl/src/ssl/mod.rs
+++ b/openssl/src/ssl/mod.rs
@@ -1,6 +1,6 @@
//! SSL/TLS support.
//!
-//! The `SslConnector` and `SslAcceptor` should be used in most cases - they handle
+//! `SslConnector` and `SslAcceptor` should be used in most cases - they handle
//! configuration of the OpenSSL primitives for you.
//!
//! # Examples
@@ -70,7 +70,9 @@
//! }
//! }
//! ```
+use ffi;
use libc::{c_int, c_void, c_long, c_ulong};
+use libc::{c_uchar, c_uint};
use std::any::Any;
use std::any::TypeId;
use std::cmp;
@@ -79,15 +81,14 @@ use std::ffi::{CStr, CString};
use std::fmt;
use std::io;
use std::io::prelude::*;
+use std::marker::PhantomData;
use std::mem;
+use std::ops::{Deref, DerefMut};
use std::path::Path;
use std::ptr;
+use std::slice;
use std::str;
use std::sync::Mutex;
-use libc::{c_uchar, c_uint};
-use std::slice;
-use std::marker::PhantomData;
-use ffi;
use {init, cvt, cvt_p};
use dh::DhRef;
@@ -781,6 +782,20 @@ impl OpenSslType for SslCipher {
}
}
+impl Deref for SslCipher {
+ type Target = SslCipherRef;
+
+ fn deref(&self) -> &SslCipherRef {
+ unsafe { SslCipherRef::from_ptr(self.0) }
+ }
+}
+
+impl DerefMut for SslCipher {
+ fn deref_mut(&mut self) -> &mut SslCipherRef {
+ unsafe { SslCipherRef::from_ptr_mut(self.0) }
+ }
+}
+
pub struct SslCipherRef(Opaque);
impl OpenSslTypeRef for SslCipherRef {
@@ -789,7 +804,7 @@ impl OpenSslTypeRef for SslCipherRef {
impl SslCipherRef {
/// Returns the name of cipher.
- pub fn name(&self) -> &'static str {
+ pub fn name(&self) -> &str {
let name = unsafe {
let ptr = ffi::SSL_CIPHER_get_name(self.as_ptr());
CStr::from_ptr(ptr as *const _)
@@ -799,7 +814,7 @@ impl SslCipherRef {
}
/// Returns the SSL/TLS protocol version that first defined the cipher.
- pub fn version(&self) -> &'static str {
+ pub fn version(&self) -> &str {
let version = unsafe {
let ptr = ffi::SSL_CIPHER_get_version(self.as_ptr());
CStr::from_ptr(ptr as *const _)