Skip to content
This repository was archived by the owner on Oct 30, 2019. It is now read-only.

Commit 4e027e2

Browse files
bryandmcyoshuawuyts
authored andcommitted
Renamed all types that return a Future to have the suffix of 'Future' (#41)
* Renamed all types that return a Future to have the suffix of 'Future' in preparation for filesystem support where that is the only logical pattern. For example Connect (the struct returned from TcpStream::connect(..)) returns a ConnectFuture instead of the original Connect. Closes: #40 * Set JoinHandleFuture type back to the original JoinHandle for consistency.
1 parent fffddfc commit 4e027e2

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

src/net/tcp.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ impl TcpStream {
9292
/// let stream = TcpStream::connect("127.0.0.1:0").await?;
9393
/// # Ok(())}
9494
/// ```
95-
pub fn connect<A: ToSocketAddrs>(addr: A) -> Connect {
96-
Connect {
95+
pub fn connect<A: ToSocketAddrs>(addr: A) -> ConnectFuture {
96+
ConnectFuture {
9797
addrs: Some(addr.to_socket_addrs().map(|iter| iter.collect())),
9898
last_err: None,
9999
future: None,
@@ -218,14 +218,14 @@ impl AsyncWrite for TcpStream {
218218
/// [`TcpStream::connect`]: struct.TcpStream.html#method.connect
219219
/// [`TcpStream`]: struct.TcpStream.html
220220
#[must_use = "futures do nothing unless you `.await` or poll them"]
221-
pub struct Connect {
221+
pub struct ConnectFuture {
222222
addrs: Option<io::Result<VecDeque<SocketAddr>>>,
223223
last_err: Option<io::Error>,
224224
future: Option<BoxFuture<'static, io::Result<Pin<Box<dyn runtime_raw::TcpStream>>>>>,
225225
runtime: &'static dyn runtime_raw::Runtime,
226226
}
227227

228-
impl Future for Connect {
228+
impl Future for ConnectFuture {
229229
type Output = io::Result<TcpStream>;
230230

231231
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
@@ -267,7 +267,7 @@ impl Future for Connect {
267267
}
268268
}
269269

270-
impl fmt::Debug for Connect {
270+
impl fmt::Debug for ConnectFuture {
271271
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
272272
f.debug_struct("Connect")
273273
.field("addrs", &self.addrs)
@@ -413,8 +413,8 @@ impl TcpListener {
413413
/// }
414414
/// # Ok(())}
415415
/// ```
416-
pub fn incoming(&mut self) -> Incoming<'_> {
417-
Incoming { inner: self }
416+
pub fn incoming(&mut self) -> IncomingStream<'_> {
417+
IncomingStream { inner: self }
418418
}
419419

420420
/// Handle an incoming connection.
@@ -441,9 +441,9 @@ impl TcpListener {
441441
/// println!("Connected to {}", addr);
442442
/// # Ok(())}
443443
/// ```
444-
pub fn accept(&mut self) -> Accept<'_> {
444+
pub fn accept(&mut self) -> AcceptFuture<'_> {
445445
let incoming = self.incoming();
446-
Accept { inner: incoming }
446+
AcceptFuture { inner: incoming }
447447
}
448448
}
449449

@@ -455,11 +455,11 @@ impl TcpListener {
455455
/// [`TcpStream`]: struct.TcpStream.html
456456
#[must_use = "futures do nothing unless you `.await` or poll them"]
457457
#[derive(Debug)]
458-
pub struct Accept<'stream> {
459-
inner: Incoming<'stream>,
458+
pub struct AcceptFuture<'stream> {
459+
inner: IncomingStream<'stream>,
460460
}
461461

462-
impl<'stream> Future for Accept<'stream> {
462+
impl<'stream> Future for AcceptFuture<'stream> {
463463
type Output = io::Result<(TcpStream, SocketAddr)>;
464464

465465
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
@@ -479,11 +479,11 @@ impl<'stream> Future for Accept<'stream> {
479479
/// [`TcpListener`]: struct.TcpStream.html
480480
#[must_use = "streams do nothing unless polled"]
481481
#[derive(Debug)]
482-
pub struct Incoming<'listener> {
482+
pub struct IncomingStream<'listener> {
483483
inner: &'listener mut TcpListener,
484484
}
485485

486-
impl<'listener> Stream for Incoming<'listener> {
486+
impl<'listener> Stream for IncomingStream<'listener> {
487487
type Item = io::Result<TcpStream>;
488488

489489
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {

src/net/udp.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,12 @@ impl UdpSocket {
144144
&'socket mut self,
145145
buf: &'buf [u8],
146146
addr: A,
147-
) -> SendTo<'socket, 'buf> {
147+
) -> SendToFuture<'socket, 'buf> {
148148
let addr = addr
149149
.to_socket_addrs()
150150
.map(|mut iter| iter.next())
151151
.transpose();
152-
SendTo {
152+
SendToFuture {
153153
buf,
154154
addr,
155155
socket: self,
@@ -179,8 +179,8 @@ impl UdpSocket {
179179
pub fn recv_from<'socket, 'buf>(
180180
&'socket mut self,
181181
buf: &'buf mut [u8],
182-
) -> RecvFrom<'socket, 'buf> {
183-
RecvFrom { buf, socket: self }
182+
) -> RecvFromFuture<'socket, 'buf> {
183+
RecvFromFuture { buf, socket: self }
184184
}
185185

186186
/// Gets the value of the `SO_BROADCAST` option for this socket.
@@ -360,7 +360,7 @@ impl UdpSocket {
360360
/// [`UdpSocket::send_to`]: struct.UdpSocket.html#method.send_to
361361
#[must_use = "futures do nothing unless you `.await` or poll them"]
362362
#[derive(Debug)]
363-
pub struct SendTo<'socket, 'buf> {
363+
pub struct SendToFuture<'socket, 'buf> {
364364
/// The open socket we use to send the message from.
365365
socket: &'socket mut UdpSocket,
366366
/// The message we're trying to send.
@@ -369,11 +369,11 @@ pub struct SendTo<'socket, 'buf> {
369369
addr: Option<io::Result<SocketAddr>>,
370370
}
371371

372-
impl<'socket, 'buf> Future for SendTo<'socket, 'buf> {
372+
impl<'socket, 'buf> Future for SendToFuture<'socket, 'buf> {
373373
type Output = io::Result<usize>;
374374

375375
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
376-
let SendTo { socket, buf, addr } = &mut *self;
376+
let SendToFuture { socket, buf, addr } = &mut *self;
377377
let addr = match addr.take() {
378378
Some(addr) => addr?,
379379
None => {
@@ -395,16 +395,16 @@ impl<'socket, 'buf> Future for SendTo<'socket, 'buf> {
395395
/// [`UdpSocket::recv_from`]: struct.UdpSocket.html#method.recv_from
396396
#[must_use = "futures do nothing unless you `.await` or poll them"]
397397
#[derive(Debug)]
398-
pub struct RecvFrom<'socket, 'buf> {
398+
pub struct RecvFromFuture<'socket, 'buf> {
399399
socket: &'socket mut UdpSocket,
400400
buf: &'buf mut [u8],
401401
}
402402

403-
impl<'socket, 'buf> Future for RecvFrom<'socket, 'buf> {
403+
impl<'socket, 'buf> Future for RecvFromFuture<'socket, 'buf> {
404404
type Output = io::Result<(usize, SocketAddr)>;
405405

406406
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
407-
let RecvFrom { socket, buf } = &mut *self;
407+
let RecvFromFuture { socket, buf } = &mut *self;
408408
socket.inner.as_mut().poll_recv_from(cx, buf)
409409
}
410410
}

0 commit comments

Comments
 (0)