diff options
| author | Steven Fackler <[email protected]> | 2016-05-02 20:22:00 -0700 |
|---|---|---|
| committer | Steven Fackler <[email protected]> | 2016-05-03 20:24:07 -0700 |
| commit | 00f517d2cdb10dfe113caa1476c85a3b57722eae (patch) | |
| tree | 5b228db5be806c5b518173f0d29f2bcca71112a9 | |
| parent | Drop is_dtls methods on SslMethod (diff) | |
| download | rust-openssl-00f517d2cdb10dfe113caa1476c85a3b57722eae.tar.xz rust-openssl-00f517d2cdb10dfe113caa1476c85a3b57722eae.zip | |
Drop MaybeSslStream
It should be inlined into crates that depend on it.
| -rw-r--r-- | openssl/src/ssl/mod.rs | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/openssl/src/ssl/mod.rs b/openssl/src/ssl/mod.rs index f9ba99ca..08f85dfb 100644 --- a/openssl/src/ssl/mod.rs +++ b/openssl/src/ssl/mod.rs @@ -1295,64 +1295,3 @@ impl<'a> IntoSsl for &'a SslContext { Ssl::new(self) } } - -/// A utility type to help in cases where the use of SSL is decided at runtime. -#[derive(Debug)] -pub enum MaybeSslStream<S> - where S: Read + Write -{ - /// A connection using SSL - Ssl(SslStream<S>), - /// A connection not using SSL - Normal(S), -} - -impl<S> Read for MaybeSslStream<S> where S: Read + Write -{ - fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> { - match *self { - MaybeSslStream::Ssl(ref mut s) => s.read(buf), - MaybeSslStream::Normal(ref mut s) => s.read(buf), - } - } -} - -impl<S> Write for MaybeSslStream<S> where S: Read + Write -{ - fn write(&mut self, buf: &[u8]) -> io::Result<usize> { - match *self { - MaybeSslStream::Ssl(ref mut s) => s.write(buf), - MaybeSslStream::Normal(ref mut s) => s.write(buf), - } - } - - fn flush(&mut self) -> io::Result<()> { - match *self { - MaybeSslStream::Ssl(ref mut s) => s.flush(), - MaybeSslStream::Normal(ref mut s) => s.flush(), - } - } -} - -impl<S> MaybeSslStream<S> where S: Read + Write -{ - /// Returns a reference to the underlying stream. - pub fn get_ref(&self) -> &S { - match *self { - MaybeSslStream::Ssl(ref s) => s.get_ref(), - MaybeSslStream::Normal(ref s) => s, - } - } - - /// Returns a mutable reference to the underlying stream. - /// - /// ## Warning - /// - /// It is inadvisable to read from or write to the underlying stream. - pub fn get_mut(&mut self) -> &mut S { - match *self { - MaybeSslStream::Ssl(ref mut s) => s.get_mut(), - MaybeSslStream::Normal(ref mut s) => s, - } - } -} |