Skip to content

Commit 8fcce95

Browse files
committed
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.
1 parent 259996d commit 8fcce95

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

examples/echo-threads.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ fn worker(rx: mpsc::UnboundedReceiver<net::TcpStream>) {
7979
// using the `TcpStream::from_stream` API. After that the socket is not
8080
// a `tokio::net::TcpStream` meaning it's in nonblocking mode and
8181
// ready to be used with Tokio
82-
let socket = TcpStream::from_stream(socket, &handle)
82+
let socket = TcpStream::from_std(socket, &handle)
8383
.expect("failed to associate TCP stream");
8484
let addr = socket.peer_addr().expect("failed to get remote address");
8585

examples/tinyhttp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ fn worker(rx: mpsc::UnboundedReceiver<net::TcpStream>) {
8181
// request/response types instead of bytes. Here we'll just use our
8282
// framing defined below and then use the `send_all` helper to send the
8383
// responses back on the socket after we've processed them
84-
let socket = future::result(TcpStream::from_stream(socket, &handle));
84+
let socket = future::result(TcpStream::from_std(socket, &handle));
8585
let req = socket.and_then(|socket| {
8686
let (tx, rx) = socket.framed(Http).split();
8787
tx.send_all(rx.and_then(respond))

src/net/tcp.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@ impl TcpListener {
103103
/// will only be for the same IP version as `addr` specified. That is, if
104104
/// `addr` is an IPv4 address then all sockets accepted will be IPv4 as
105105
/// well (same for IPv6).
106-
pub fn from_listener(listener: net::TcpListener,
107-
addr: &SocketAddr,
108-
handle: &Handle) -> io::Result<TcpListener> {
109-
let l = try!(mio::net::TcpListener::from_listener(listener, addr));
106+
pub fn from_std(listener: net::TcpListener,
107+
addr: &SocketAddr,
108+
handle: &Handle) -> io::Result<TcpListener> {
109+
let l = mio::net::TcpListener::from_listener(listener, addr)?;
110110
TcpListener::new(l, handle)
111111
}
112112

@@ -252,9 +252,10 @@ impl TcpStream {
252252
/// to a TCP stream ready to be used with the provided event loop handle.
253253
/// The stream returned is associated with the event loop and ready to
254254
/// perform I/O.
255-
pub fn from_stream(stream: net::TcpStream, handle: &Handle)
256-
-> io::Result<TcpStream> {
257-
let inner = try!(mio::net::TcpStream::from_stream(stream));
255+
pub fn from_std(stream: net::TcpStream, handle: &Handle)
256+
-> io::Result<TcpStream>
257+
{
258+
let inner = mio::net::TcpStream::from_stream(stream)?;
258259
Ok(TcpStream {
259260
io: try!(PollEvented::new(inner, handle)),
260261
})
@@ -278,10 +279,11 @@ impl TcpStream {
278279
/// loop. Note that on Windows you must `bind` a socket before it can be
279280
/// connected, so if a custom `TcpBuilder` is used it should be bound
280281
/// (perhaps to `INADDR_ANY`) before this method is called.
281-
pub fn connect_stream(stream: net::TcpStream,
282-
addr: &SocketAddr,
283-
handle: &Handle)
284-
-> Box<Future<Item=TcpStream, Error=io::Error> + Send> {
282+
pub fn connect_std(stream: net::TcpStream,
283+
addr: &SocketAddr,
284+
handle: &Handle)
285+
-> Box<Future<Item=TcpStream, Error=io::Error> + Send>
286+
{
285287
let state = match mio::net::TcpStream::connect_stream(stream, addr) {
286288
Ok(tcp) => TcpStream::new(tcp, handle),
287289
Err(e) => TcpStreamNewState::Error(e),

src/net/udp/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ impl UdpSocket {
3737
/// This can be used in conjunction with net2's `UdpBuilder` interface to
3838
/// configure a socket before it's handed off, such as setting options like
3939
/// `reuse_address` or binding to multiple addresses.
40-
pub fn from_socket(socket: net::UdpSocket,
41-
handle: &Handle) -> io::Result<UdpSocket> {
40+
pub fn from_std(socket: net::UdpSocket,
41+
handle: &Handle) -> io::Result<UdpSocket> {
4242
let udp = try!(mio::net::UdpSocket::from_socket(socket));
4343
UdpSocket::new(udp, handle)
4444
}

0 commit comments

Comments
 (0)