Implement try_clone for MaybeSslStream

Closes #308
This commit is contained in:
Steven Fackler 2015-11-20 21:33:10 -08:00
parent bfba91296c
commit 6bb3d8f1b5
1 changed files with 10 additions and 0 deletions

View File

@ -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> {