mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-22 00:00:11 +02:00
Touch up TcpStream::from_stream
This commit is contained in:
+1
-1
@@ -19,7 +19,7 @@ appveyor = { repository = "alexcrichton/tokio-core" }
|
||||
[dependencies]
|
||||
futures = "0.1.9"
|
||||
log = "0.3"
|
||||
mio = "0.6"
|
||||
mio = "0.6.4"
|
||||
scoped-tls = "0.1.0"
|
||||
slab = "0.3"
|
||||
|
||||
|
||||
+8
-2
@@ -267,9 +267,15 @@ impl TcpStream {
|
||||
}
|
||||
|
||||
/// Create a new `TcpStream` from a `net::TcpStream`.
|
||||
pub fn from_stream(stream: net::TcpStream, handle: &Handle) -> io::Result<TcpStream> {
|
||||
///
|
||||
/// This function will convert a TCP stream in the standard library to a TCP
|
||||
/// stream ready to be used with the provided event loop handle. The object
|
||||
/// returned is associated with the event loop and ready to perform I/O.
|
||||
pub fn from_stream(stream: net::TcpStream, handle: &Handle)
|
||||
-> io::Result<TcpStream> {
|
||||
let inner = try!(mio::tcp::TcpStream::from_stream(stream));
|
||||
Ok(TcpStream {
|
||||
io: try!(PollEvented::new(try!(mio::tcp::TcpStream::from_stream(stream)), handle)),
|
||||
io: try!(PollEvented::new(inner, handle)),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user