mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-16 00:00:12 +02:00
Rename networking constructors with _std
This commit renames the various constructors of networking types to have a `_std` suffix instead of a smorgasboard of other suffixes, canonicalizing on `_std` as the suffix for constructors which take the libstd corresponding types.
This commit is contained in:
@@ -79,7 +79,7 @@ fn worker(rx: mpsc::UnboundedReceiver<net::TcpStream>) {
|
||||
// using the `TcpStream::from_stream` API. After that the socket is not
|
||||
// a `tokio::net::TcpStream` meaning it's in nonblocking mode and
|
||||
// ready to be used with Tokio
|
||||
let socket = TcpStream::from_stream(socket, &handle)
|
||||
let socket = TcpStream::from_std(socket, &handle)
|
||||
.expect("failed to associate TCP stream");
|
||||
let addr = socket.peer_addr().expect("failed to get remote address");
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ fn worker(rx: mpsc::UnboundedReceiver<net::TcpStream>) {
|
||||
// request/response types instead of bytes. Here we'll just use our
|
||||
// framing defined below and then use the `send_all` helper to send the
|
||||
// responses back on the socket after we've processed them
|
||||
let socket = future::result(TcpStream::from_stream(socket, &handle));
|
||||
let socket = future::result(TcpStream::from_std(socket, &handle));
|
||||
let req = socket.and_then(|socket| {
|
||||
let (tx, rx) = socket.framed(Http).split();
|
||||
tx.send_all(rx.and_then(respond))
|
||||
|
||||
+13
-11
@@ -103,10 +103,10 @@ impl TcpListener {
|
||||
/// will only be for the same IP version as `addr` specified. That is, if
|
||||
/// `addr` is an IPv4 address then all sockets accepted will be IPv4 as
|
||||
/// well (same for IPv6).
|
||||
pub fn from_listener(listener: net::TcpListener,
|
||||
addr: &SocketAddr,
|
||||
handle: &Handle) -> io::Result<TcpListener> {
|
||||
let l = try!(mio::net::TcpListener::from_listener(listener, addr));
|
||||
pub fn from_std(listener: net::TcpListener,
|
||||
addr: &SocketAddr,
|
||||
handle: &Handle) -> io::Result<TcpListener> {
|
||||
let l = mio::net::TcpListener::from_listener(listener, addr)?;
|
||||
TcpListener::new(l, handle)
|
||||
}
|
||||
|
||||
@@ -252,9 +252,10 @@ impl TcpStream {
|
||||
/// to a TCP stream ready to be used with the provided event loop handle.
|
||||
/// The stream 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::net::TcpStream::from_stream(stream));
|
||||
pub fn from_std(stream: net::TcpStream, handle: &Handle)
|
||||
-> io::Result<TcpStream>
|
||||
{
|
||||
let inner = mio::net::TcpStream::from_stream(stream)?;
|
||||
Ok(TcpStream {
|
||||
io: try!(PollEvented::new(inner, handle)),
|
||||
})
|
||||
@@ -278,10 +279,11 @@ impl TcpStream {
|
||||
/// loop. Note that on Windows you must `bind` a socket before it can be
|
||||
/// connected, so if a custom `TcpBuilder` is used it should be bound
|
||||
/// (perhaps to `INADDR_ANY`) before this method is called.
|
||||
pub fn connect_stream(stream: net::TcpStream,
|
||||
addr: &SocketAddr,
|
||||
handle: &Handle)
|
||||
-> Box<Future<Item=TcpStream, Error=io::Error> + Send> {
|
||||
pub fn connect_std(stream: net::TcpStream,
|
||||
addr: &SocketAddr,
|
||||
handle: &Handle)
|
||||
-> Box<Future<Item=TcpStream, Error=io::Error> + Send>
|
||||
{
|
||||
let state = match mio::net::TcpStream::connect_stream(stream, addr) {
|
||||
Ok(tcp) => TcpStream::new(tcp, handle),
|
||||
Err(e) => TcpStreamNewState::Error(e),
|
||||
|
||||
+2
-2
@@ -37,8 +37,8 @@ impl UdpSocket {
|
||||
/// This can be used in conjunction with net2's `UdpBuilder` interface to
|
||||
/// configure a socket before it's handed off, such as setting options like
|
||||
/// `reuse_address` or binding to multiple addresses.
|
||||
pub fn from_socket(socket: net::UdpSocket,
|
||||
handle: &Handle) -> io::Result<UdpSocket> {
|
||||
pub fn from_std(socket: net::UdpSocket,
|
||||
handle: &Handle) -> io::Result<UdpSocket> {
|
||||
let udp = try!(mio::net::UdpSocket::from_socket(socket));
|
||||
UdpSocket::new(udp, handle)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user