diff options
| author | Steven Fackler <[email protected]> | 2015-11-20 21:33:10 -0800 |
|---|---|---|
| committer | Steven Fackler <[email protected]> | 2015-11-20 21:33:36 -0800 |
| commit | 6bb3d8f1b5827ff27216d4219e08467b2461c071 (patch) | |
| tree | bbefdfbb9ecf71bdde085c51fa255af0b73072e3 | |
| parent | Merge pull request #307 from alex/patch-1 (diff) | |
| download | rust-openssl-6bb3d8f1b5827ff27216d4219e08467b2461c071.tar.xz rust-openssl-6bb3d8f1b5827ff27216d4219e08467b2461c071.zip | |
Implement try_clone for MaybeSslStream
Closes #308
| -rw-r--r-- | openssl/src/ssl/mod.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/openssl/src/ssl/mod.rs b/openssl/src/ssl/mod.rs index 2775c4c8..cca369a2 100644 --- a/openssl/src/ssl/mod.rs +++ b/openssl/src/ssl/mod.rs @@ -1416,6 +1416,16 @@ impl<S> MaybeSslStream<S> where S: Read+Write { } } +impl MaybeSslStream<net::TcpStream> { + /// Like `TcpStream::try_clone`. + pub fn try_clone(&self) -> io::Result<MaybeSslStream<net::TcpStream>> { + match *self { + MaybeSslStream::Ssl(ref s) => s.try_clone().map(MaybeSslStream::Ssl), + MaybeSslStream::Normal(ref s) => s.try_clone().map(MaybeSslStream::Normal), + } + } +} + /// An SSL stream wrapping a nonblocking socket. #[derive(Clone)] pub struct NonblockingSslStream<S> { |