Commit c3eee3b1 authored by Aaron Weiss's avatar Aaron Weiss
Browse files

Added try_clone to SslStream for SslStream<TcpStream>.

parent 5154581c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
#![feature(unsafe_destructor, core, io, std_misc, path, os, unique)]
#![feature(unsafe_destructor, core, io, std_misc, net, path, os, unique)]
#![cfg_attr(test, feature(net, fs))]
#![doc(html_root_url="https://sfackler.github.io/rust-openssl/doc/openssl")]

+12 −0
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ use std::io;
use std::io::prelude::*;
use std::ffi::AsOsStr;
use std::mem;
use std::net;
use std::num::FromPrimitive;
use std::num::Int;
use std::path::Path;
@@ -437,6 +438,17 @@ pub struct SslStream<S> {
    buf: Vec<u8>
}

impl SslStream<net::TcpStream> {
    /// Create a new independently owned handle to the underlying socket.
    pub fn try_clone(&self) -> io::Result<SslStream<net::TcpStream>> {
        Ok(SslStream { 
            stream: try!(self.stream.try_clone()),
            ssl: self.ssl.clone(),
            buf: self.buf.clone(),
        })
    }
}

impl<S> fmt::Debug for SslStream<S> where S: fmt::Debug {
    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
        write!(fmt, "SslStream {{ stream: {:?}, ssl: {:?} }}", self.stream, self.ssl)