From c1f1320203c7c5124bdd7684fae18dd48506d3a5 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 24 Jan 2017 23:45:43 +0100 Subject: [PATCH] Add from_stream method --- src/net/tcp.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/net/tcp.rs b/src/net/tcp.rs index f5b3ccfb3..2de04d4dd 100644 --- a/src/net/tcp.rs +++ b/src/net/tcp.rs @@ -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 { + 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. ///