From 696b1961ce31e77aebf5fcf13398c8c54ed22d87 Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Sun, 1 May 2016 21:02:29 -0700 Subject: [PATCH] Rename getters in line with conventions --- openssl/src/ssl/mod.rs | 16 +++++++--------- openssl/src/ssl/tests/mod.rs | 4 ++-- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/openssl/src/ssl/mod.rs b/openssl/src/ssl/mod.rs index 55a97c94..1bb4a2d8 100644 --- a/openssl/src/ssl/mod.rs +++ b/openssl/src/ssl/mod.rs @@ -767,7 +767,7 @@ impl SslContext { 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) }; SslContextOptions::from_bits(ret).unwrap() } @@ -982,7 +982,7 @@ impl Ssl { } } - pub fn get_current_cipher<'a>(&'a self) -> Option> { + pub fn current_cipher<'a>(&'a self) -> Option> { unsafe { let ptr = ffi::SSL_get_current_cipher(self.ssl); @@ -1119,7 +1119,7 @@ impl Ssl { Some(s) } - pub fn get_ssl_method(&self) -> Option { + pub fn ssl_method(&self) -> Option { unsafe { let method = ffi::SSL_get_ssl_method(self.ssl); SslMethod::from_raw(method) @@ -1127,7 +1127,7 @@ impl Ssl { } /// Returns the server's name for the current connection - pub fn get_servername(&self) -> Option { + pub fn servername(&self) -> Option { let name = unsafe { ffi::SSL_get_servername(self.ssl, ffi::TLSEXT_NAMETYPE_host_name) }; if name == ptr::null() { return None; @@ -1136,9 +1136,7 @@ impl Ssl { unsafe { String::from_utf8(CStr::from_ptr(name as *const _).to_bytes().to_vec()).ok() } } - /// change the context corresponding to the current connection - /// - /// Returns a clone of the SslContext @ctx (ie: the new context). The old context is freed. + /// Changes the context corresponding to the current connection. pub fn set_ssl_context(&self, ctx: &SslContext) -> Result<(), ErrorStack> { unsafe { try_ssl_null!(ffi::SSL_set_SSL_CTX(self.ssl, ctx.ctx)); @@ -1146,8 +1144,8 @@ impl Ssl { Ok(()) } - /// obtain the context corresponding to the current connection - pub fn get_ssl_context(&self) -> SslContext { + /// Returns the context corresponding to the current connection + pub fn ssl_context(&self) -> SslContext { unsafe { let ssl_ctx = ffi::SSL_get_SSL_CTX(self.ssl); SslContext::new_ref(ssl_ctx) diff --git a/openssl/src/ssl/tests/mod.rs b/openssl/src/ssl/tests/mod.rs index 7f0f3415..e3b0a340 100644 --- a/openssl/src/ssl/tests/mod.rs +++ b/openssl/src/ssl/tests/mod.rs @@ -227,7 +227,7 @@ run_test!(new_sslstream, |method, stream| { run_test!(get_ssl_method, |method, _| { 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| { @@ -462,7 +462,7 @@ fn test_set_certificate_and_private_key() { run_test!(get_ctx_options, |method, _| { let mut ctx = SslContext::new(method).unwrap(); - ctx.get_options(); + ctx.options(); }); run_test!(set_ctx_options, |method, _| {