mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-09-06 00:00:10 +02:00
Update TcpStream::connect_stream() to return TcpStreamNew
This commit is contained in:
+6
-5
@@ -227,7 +227,7 @@ pub struct TcpStreamNew {
|
|||||||
inner: TcpStreamNewFuture,
|
inner: TcpStreamNewFuture,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type TcpStreamNewConnected = ::futures::AndThen<
|
type TcpStreamNewConnected = ::futures::AndThen<
|
||||||
::futures::future::FutureResult<
|
::futures::future::FutureResult<
|
||||||
::reactor::PollEvented<::mio::tcp::TcpStream>,
|
::reactor::PollEvented<::mio::tcp::TcpStream>,
|
||||||
::std::io::Error,
|
::std::io::Error,
|
||||||
@@ -236,7 +236,7 @@ pub type TcpStreamNewConnected = ::futures::AndThen<
|
|||||||
fn (::reactor::PollEvented<::mio::tcp::TcpStream>) -> ::net::tcp::TcpStreamConnect
|
fn (::reactor::PollEvented<::mio::tcp::TcpStream>) -> ::net::tcp::TcpStreamConnect
|
||||||
>;
|
>;
|
||||||
|
|
||||||
pub enum TcpStreamNewFuture {
|
enum TcpStreamNewFuture {
|
||||||
Connected(TcpStreamNewConnected),
|
Connected(TcpStreamNewConnected),
|
||||||
Error(::futures::future::Err<TcpStream, ::std::io::Error>),
|
Error(::futures::future::Err<TcpStream, ::std::io::Error>),
|
||||||
}
|
}
|
||||||
@@ -308,11 +308,12 @@ impl TcpStream {
|
|||||||
/// (perhaps to `INADDR_ANY`) before this method is called.
|
/// (perhaps to `INADDR_ANY`) before this method is called.
|
||||||
pub fn connect_stream(stream: net::TcpStream,
|
pub fn connect_stream(stream: net::TcpStream,
|
||||||
addr: &SocketAddr,
|
addr: &SocketAddr,
|
||||||
handle: &Handle) -> TcpStreamNewFuture {
|
handle: &Handle) -> TcpStreamNew {
|
||||||
match mio::tcp::TcpStream::connect_stream(stream, addr) {
|
let future = match mio::tcp::TcpStream::connect_stream(stream, addr) {
|
||||||
Ok(tcp) => TcpStream::new(tcp, handle),
|
Ok(tcp) => TcpStream::new(tcp, handle),
|
||||||
Err(e) => TcpStreamNewFuture::Error(failed(e)),
|
Err(e) => TcpStreamNewFuture::Error(failed(e)),
|
||||||
}
|
};
|
||||||
|
TcpStreamNew { inner: future }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Test whether this socket is ready to be read or not.
|
/// Test whether this socket is ready to be read or not.
|
||||||
|
|||||||
Reference in New Issue
Block a user