diff options
| author | Steven Fackler <[email protected]> | 2015-12-17 21:26:06 -0800 |
|---|---|---|
| committer | Steven Fackler <[email protected]> | 2015-12-17 21:26:06 -0800 |
| commit | 6195bd4fd8a46ab62cbbc5f654c9743371722dc1 (patch) | |
| tree | 0ccf253c93e6d4923c75ad51744e91dd1839f97f /openssl/src/bio/mod.rs | |
| parent | Merge branch 'release-v0.7.2' into release (diff) | |
| parent | Release v0.7.3 (diff) | |
| download | rust-openssl-0.7.3.tar.xz rust-openssl-0.7.3.zip | |
Merge branch 'release-v0.7.3' into releasev0.7.3
Diffstat (limited to 'openssl/src/bio/mod.rs')
| -rw-r--r-- | openssl/src/bio/mod.rs | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/openssl/src/bio/mod.rs b/openssl/src/bio/mod.rs index a0c4b533..4c9b20b0 100644 --- a/openssl/src/bio/mod.rs +++ b/openssl/src/bio/mod.rs @@ -6,11 +6,11 @@ use std::cmp; use ffi; use ffi_extras; -use ssl::error::{SslError}; +use ssl::error::SslError; pub struct MemBio { bio: *mut ffi::BIO, - owned: bool + owned: bool, } impl Drop for MemBio { @@ -33,7 +33,7 @@ impl MemBio { Ok(MemBio { bio: bio, - owned: true + owned: true, }) } @@ -41,7 +41,7 @@ impl MemBio { pub fn borrowed(bio: *mut ffi::BIO) -> MemBio { MemBio { bio: bio, - owned: false + owned: false, } } @@ -60,17 +60,21 @@ impl MemBio { /// Sets the BIO's EOF state. pub fn set_eof(&self, eof: bool) { - let v = if eof { 0 } else { -1 }; - unsafe { ffi_extras::BIO_set_mem_eof_return(self.bio, v); } + let v = if eof { + 0 + } else { + -1 + }; + unsafe { + ffi_extras::BIO_set_mem_eof_return(self.bio, v); + } } } impl Read for MemBio { fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> { let len = cmp::min(c_int::max_value() as usize, buf.len()) as c_int; - let ret = unsafe { - ffi::BIO_read(self.bio, buf.as_ptr() as *mut c_void, len) - }; + let ret = unsafe { ffi::BIO_read(self.bio, buf.as_ptr() as *mut c_void, len) }; if ret <= 0 { let is_eof = unsafe { ffi_extras::BIO_eof(self.bio) }; @@ -88,9 +92,7 @@ impl Read for MemBio { impl Write for MemBio { fn write(&mut self, buf: &[u8]) -> io::Result<usize> { let len = cmp::min(c_int::max_value() as usize, buf.len()) as c_int; - let ret = unsafe { - ffi::BIO_write(self.bio, buf.as_ptr() as *const c_void, len) - }; + let ret = unsafe { ffi::BIO_write(self.bio, buf.as_ptr() as *const c_void, len) }; if ret < 0 { Err(io::Error::new(io::ErrorKind::Other, SslError::get())) |