Add from_stream method

This commit is contained in:
Guillaume Gomez 2017-01-24 23:45:43 +01:00
parent e8d4524586
commit c1f1320203

View File

@ -257,6 +257,13 @@ impl TcpStream {
}
}
/// Create a new `TcpStream` from a `net::TcpStream`.
pub fn from_stream(stream: net::TcpStream, handle: &Handle) -> io::Result<TcpStream> {
Ok(TcpStream {
io: try!(PollEvented::new(try!(mio::tcp::TcpStream::from_stream(stream)), handle)),
})
}
/// Creates a new `TcpStream` from the pending socket inside the given
/// `std::net::TcpStream`, connecting it to the address specified.
///