aboutsummaryrefslogtreecommitdiff
path: root/openssl/src/ssl/mod.rs
diff options
context:
space:
mode:
authorSteven Fackler <[email protected]>2016-01-30 10:41:47 -0800
committerSteven Fackler <[email protected]>2016-05-03 20:24:07 -0700
commitde47d158c20768b8526e939e7eb3ae9175e282f2 (patch)
treec154b16f108fd399ff06499b1317ce50fb5e1e56 /openssl/src/ssl/mod.rs
parentUpdate openssl version in CI (diff)
downloadrust-openssl-de47d158c20768b8526e939e7eb3ae9175e282f2.tar.xz
rust-openssl-de47d158c20768b8526e939e7eb3ae9175e282f2.zip
Remove NonblockingSslStream
Diffstat (limited to 'openssl/src/ssl/mod.rs')
-rw-r--r--openssl/src/ssl/mod.rs133
1 files changed, 1 insertions, 132 deletions
diff --git a/openssl/src/ssl/mod.rs b/openssl/src/ssl/mod.rs
index aa785142..4404eb55 100644
--- a/openssl/src/ssl/mod.rs
+++ b/openssl/src/ssl/mod.rs
@@ -26,7 +26,7 @@ use std::os::windows::io::{AsRawSocket, RawSocket};
use ffi;
use ffi_extras;
use dh::DH;
-use ssl::error::{NonblockingSslError, SslError, OpenSslError, OpensslError};
+use ssl::error::{SslError, OpenSslError};
use x509::{X509StoreContext, X509FileType, X509};
use crypto::pkey::PKey;
@@ -1572,134 +1572,3 @@ impl MaybeSslStream<net::TcpStream> {
}
}
}
-
-/// # Deprecated
-///
-/// Use `SslStream` with `ssl_read` and `ssl_write`.
-pub struct NonblockingSslStream<S>(SslStream<S>);
-
-impl<S: Clone + Read + Write> Clone for NonblockingSslStream<S> {
- fn clone(&self) -> Self {
- NonblockingSslStream(self.0.clone())
- }
-}
-
-#[cfg(unix)]
-impl<S: AsRawFd> AsRawFd for NonblockingSslStream<S> {
- fn as_raw_fd(&self) -> RawFd {
- self.0.as_raw_fd()
- }
-}
-
-#[cfg(windows)]
-impl<S: AsRawSocket> AsRawSocket for NonblockingSslStream<S> {
- fn as_raw_socket(&self) -> RawSocket {
- self.0.as_raw_socket()
- }
-}
-
-impl NonblockingSslStream<net::TcpStream> {
- pub fn try_clone(&self) -> io::Result<NonblockingSslStream<net::TcpStream>> {
- self.0.try_clone().map(NonblockingSslStream)
- }
-}
-
-impl<S> NonblockingSslStream<S> {
- /// Returns a reference to the underlying stream.
- pub fn get_ref(&self) -> &S {
- self.0.get_ref()
- }
-
- /// Returns a mutable reference to the underlying stream.
- ///
- /// ## Warning
- ///
- /// It is inadvisable to read from or write to the underlying stream as it
- /// will most likely corrupt the SSL session.
- pub fn get_mut(&mut self) -> &mut S {
- self.0.get_mut()
- }
-
- /// Returns a reference to the Ssl.
- pub fn ssl(&self) -> &Ssl {
- self.0.ssl()
- }
-}
-
-impl<S: Read + Write> NonblockingSslStream<S> {
- /// Create a new nonblocking client ssl connection on wrapped `stream`.
- ///
- /// Note that this method will most likely not actually complete the SSL
- /// handshake because doing so requires several round trips; the handshake will
- /// be completed in subsequent read/write calls managed by your event loop.
- pub fn connect<T: IntoSsl>(ssl: T, stream: S) -> Result<NonblockingSslStream<S>, SslError> {
- SslStream::connect(ssl, stream).map(NonblockingSslStream)
- }
-
- /// Create a new nonblocking server ssl connection on wrapped `stream`.
- ///
- /// Note that this method will most likely not actually complete the SSL
- /// handshake because doing so requires several round trips; the handshake will
- /// be completed in subsequent read/write calls managed by your event loop.
- pub fn accept<T: IntoSsl>(ssl: T, stream: S) -> Result<NonblockingSslStream<S>, SslError> {
- SslStream::accept(ssl, stream).map(NonblockingSslStream)
- }
-
- fn convert_err(&self, err: Error) -> NonblockingSslError {
- match err {
- Error::ZeroReturn => SslError::SslSessionClosed.into(),
- Error::WantRead(_) => NonblockingSslError::WantRead,
- Error::WantWrite(_) => NonblockingSslError::WantWrite,
- Error::WantX509Lookup => unreachable!(),
- Error::Stream(e) => SslError::StreamError(e).into(),
- Error::Ssl(e) => {
- SslError::OpenSslErrors(e.iter()
- .map(|e| OpensslError::from_error_code(e.error_code()))
- .collect())
- .into()
- }
- }
- }
-
- /// Read bytes from the SSL stream into `buf`.
- ///
- /// Given the SSL state machine, this method may return either `WantWrite`
- /// or `WantRead` to indicate that your event loop should respectively wait
- /// for write or read readiness on the underlying stream. Upon readiness,
- /// repeat your `read()` call with the same arguments each time until you
- /// receive an `Ok(count)`.
- ///
- /// An `SslError` return value, is terminal; do not re-attempt your read.
- ///
- /// As expected of a nonblocking API, this method will never block your
- /// thread on I/O.
- ///
- /// On a return value of `Ok(count)`, count is the number of decrypted
- /// plaintext bytes copied into the `buf` slice.
- pub fn read(&mut self, buf: &mut [u8]) -> Result<usize, NonblockingSslError> {
- match self.0.ssl_read(buf) {
- Ok(n) => Ok(n),
- Err(Error::ZeroReturn) => Ok(0),
- Err(e) => Err(self.convert_err(e)),
- }
- }
-
- /// Write bytes from `buf` to the SSL stream.
- ///
- /// Given the SSL state machine, this method may return either `WantWrite`
- /// or `WantRead` to indicate that your event loop should respectively wait
- /// for write or read readiness on the underlying stream. Upon readiness,
- /// repeat your `write()` call with the same arguments each time until you
- /// receive an `Ok(count)`.
- ///
- /// An `SslError` return value, is terminal; do not re-attempt your write.
- ///
- /// As expected of a nonblocking API, this method will never block your
- /// thread on I/O.
- ///
- /// Given a return value of `Ok(count)`, count is the number of plaintext bytes
- /// from the `buf` slice that were encrypted and written onto the stream.
- pub fn write(&mut self, buf: &[u8]) -> Result<usize, NonblockingSslError> {
- self.0.ssl_write(buf).map_err(|e| self.convert_err(e))
- }
-}