Rename getters in line with conventions

This commit is contained in:
Steven Fackler 2016-05-01 21:02:29 -07:00
parent a0549c1606
commit 696b1961ce
2 changed files with 9 additions and 11 deletions

View File

@ -767,7 +767,7 @@ impl SslContext {
SslContextOptions::from_bits(ret).unwrap() SslContextOptions::from_bits(ret).unwrap()
} }
pub fn get_options(&mut self) -> SslContextOptions { pub fn options(&mut self) -> SslContextOptions {
let ret = unsafe { ffi_extras::SSL_CTX_get_options(self.ctx) }; let ret = unsafe { ffi_extras::SSL_CTX_get_options(self.ctx) };
SslContextOptions::from_bits(ret).unwrap() SslContextOptions::from_bits(ret).unwrap()
} }
@ -982,7 +982,7 @@ impl Ssl {
} }
} }
pub fn get_current_cipher<'a>(&'a self) -> Option<SslCipher<'a>> { pub fn current_cipher<'a>(&'a self) -> Option<SslCipher<'a>> {
unsafe { unsafe {
let ptr = ffi::SSL_get_current_cipher(self.ssl); let ptr = ffi::SSL_get_current_cipher(self.ssl);
@ -1119,7 +1119,7 @@ impl Ssl {
Some(s) Some(s)
} }
pub fn get_ssl_method(&self) -> Option<SslMethod> { pub fn ssl_method(&self) -> Option<SslMethod> {
unsafe { unsafe {
let method = ffi::SSL_get_ssl_method(self.ssl); let method = ffi::SSL_get_ssl_method(self.ssl);
SslMethod::from_raw(method) SslMethod::from_raw(method)
@ -1127,7 +1127,7 @@ impl Ssl {
} }
/// Returns the server's name for the current connection /// Returns the server's name for the current connection
pub fn get_servername(&self) -> Option<String> { pub fn servername(&self) -> Option<String> {
let name = unsafe { ffi::SSL_get_servername(self.ssl, ffi::TLSEXT_NAMETYPE_host_name) }; let name = unsafe { ffi::SSL_get_servername(self.ssl, ffi::TLSEXT_NAMETYPE_host_name) };
if name == ptr::null() { if name == ptr::null() {
return None; return None;
@ -1136,9 +1136,7 @@ impl Ssl {
unsafe { String::from_utf8(CStr::from_ptr(name as *const _).to_bytes().to_vec()).ok() } unsafe { String::from_utf8(CStr::from_ptr(name as *const _).to_bytes().to_vec()).ok() }
} }
/// change the context corresponding to the current connection /// Changes the context corresponding to the current connection.
///
/// Returns a clone of the SslContext @ctx (ie: the new context). The old context is freed.
pub fn set_ssl_context(&self, ctx: &SslContext) -> Result<(), ErrorStack> { pub fn set_ssl_context(&self, ctx: &SslContext) -> Result<(), ErrorStack> {
unsafe { unsafe {
try_ssl_null!(ffi::SSL_set_SSL_CTX(self.ssl, ctx.ctx)); try_ssl_null!(ffi::SSL_set_SSL_CTX(self.ssl, ctx.ctx));
@ -1146,8 +1144,8 @@ impl Ssl {
Ok(()) Ok(())
} }
/// obtain the context corresponding to the current connection /// Returns the context corresponding to the current connection
pub fn get_ssl_context(&self) -> SslContext { pub fn ssl_context(&self) -> SslContext {
unsafe { unsafe {
let ssl_ctx = ffi::SSL_get_SSL_CTX(self.ssl); let ssl_ctx = ffi::SSL_get_SSL_CTX(self.ssl);
SslContext::new_ref(ssl_ctx) SslContext::new_ref(ssl_ctx)

View File

@ -227,7 +227,7 @@ run_test!(new_sslstream, |method, stream| {
run_test!(get_ssl_method, |method, _| { run_test!(get_ssl_method, |method, _| {
let ssl = Ssl::new(&SslContext::new(method).unwrap()).unwrap(); let ssl = Ssl::new(&SslContext::new(method).unwrap()).unwrap();
assert_eq!(ssl.get_ssl_method(), Some(method)); assert_eq!(ssl.ssl_method(), Some(method));
}); });
run_test!(verify_untrusted, |method, stream| { run_test!(verify_untrusted, |method, stream| {
@ -462,7 +462,7 @@ fn test_set_certificate_and_private_key() {
run_test!(get_ctx_options, |method, _| { run_test!(get_ctx_options, |method, _| {
let mut ctx = SslContext::new(method).unwrap(); let mut ctx = SslContext::new(method).unwrap();
ctx.get_options(); ctx.options();
}); });
run_test!(set_ctx_options, |method, _| { run_test!(set_ctx_options, |method, _| {