From 55775f8e2b621ee1c0a02246adfe33487a74d60e Mon Sep 17 00:00:00 2001 From: amab8901 Date: Mon, 27 Feb 2023 15:59:53 +0100 Subject: [PATCH 01/16] create async_io --- tokio/src/net/udp.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tokio/src/net/udp.rs b/tokio/src/net/udp.rs index 922a977a929..48651d948af 100644 --- a/tokio/src/net/udp.rs +++ b/tokio/src/net/udp.rs @@ -1309,6 +1309,17 @@ impl UdpSocket { .registration() .try_io(interest, || self.io.try_io(f)) } + + pub async fn async_io( + &self, + interest: Interest, + f: impl FnMut() -> io::Result, + ) -> io::Result { + self.io + .registration() + .async_io(interest, || self.io.async_io(f) ) + .await + } /// Receives data from the socket, without removing it from the input queue. /// On success, returns the number of bytes read and the address from whence From a971b63f34e9961ddbd56fd1e42a31dfda236198 Mon Sep 17 00:00:00 2001 From: amab8901 Date: Mon, 27 Feb 2023 16:01:40 +0100 Subject: [PATCH 02/16] Works now --- tokio/src/net/udp.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tokio/src/net/udp.rs b/tokio/src/net/udp.rs index 48651d948af..4e3862fe49a 100644 --- a/tokio/src/net/udp.rs +++ b/tokio/src/net/udp.rs @@ -1310,14 +1310,15 @@ impl UdpSocket { .try_io(interest, || self.io.try_io(f)) } + /// lol pub async fn async_io( &self, interest: Interest, - f: impl FnMut() -> io::Result, + mut f: impl FnMut() -> io::Result, ) -> io::Result { self.io .registration() - .async_io(interest, || self.io.async_io(f) ) + .async_io(interest, || self.io.try_io(&mut f) ) .await } From 9e355b9e52969085ac065e038c82eead70c5b467 Mon Sep 17 00:00:00 2001 From: amab8901 Date: Mon, 27 Feb 2023 16:09:15 +0100 Subject: [PATCH 03/16] Add comments --- tokio/src/net/udp.rs | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/tokio/src/net/udp.rs b/tokio/src/net/udp.rs index 4e3862fe49a..8c255f187e1 100644 --- a/tokio/src/net/udp.rs +++ b/tokio/src/net/udp.rs @@ -1310,7 +1310,37 @@ impl UdpSocket { .try_io(interest, || self.io.try_io(f)) } - /// lol + /// Reads or writes from the socket using a user-provided IO operation. + /// + /// The readiness of the socket is awaited and when the socket is ready, + /// the provided closure is called. The closure should attempt to perform + /// IO operation on the socket by manually calling the appropriate syscall. + /// If the operation fails because the socket is not actually ready, + /// then the closure should return a `WouldBlock` error, the readiness + /// flag is cleared and the socket readiness is awaited again. This loop + /// repeated until the closure returns an `Ok` or an error that doesn't + /// have the `WouldBlock` value. + /// + /// The closure should only return a `WouldBlock` error if it has performed + /// an IO operation on the socket that failed due to the socket not being + /// ready. Returning a `WouldBlock` error in any other situation will + /// incorrectly clear the readiness flag, which can cause the socket to + /// behave incorrectly. + /// + /// The closure should not perform the IO operation using any of the methods + /// defined on the Tokio `UdpSocket` type, as this will mess with the + /// readiness flag and can cause the socket to behave incorrectly. + /// + /// This method is not intended to be used with combined interests. + /// The closure should perform only one type of IO operation, so it should not + /// require more than one ready state. This method may panic or sleep forever + /// if it is called with a combined interest. + /// + /// Usually, [`readable()`], [`writable()`] or [`ready()`] is used with this function. + /// + /// [`readable()`]: UdpSocket::readable() + /// [`writable()`]: UdpSocket::writable() + /// [`ready()`]: UdpSocket::ready() pub async fn async_io( &self, interest: Interest, From e9293cc1bb006691d8e218cff1900fc25c38b8e3 Mon Sep 17 00:00:00 2001 From: amab8901 Date: Mon, 27 Feb 2023 16:40:36 +0100 Subject: [PATCH 04/16] Apply async_io to all IO assets --- tokio/src/net/tcp/stream.rs | 42 ++++++++++++++ tokio/src/net/unix/datagram/socket.rs | 42 ++++++++++++++ tokio/src/net/unix/stream.rs | 42 ++++++++++++++ tokio/src/net/windows/named_pipe.rs | 84 +++++++++++++++++++++++++++ 4 files changed, 210 insertions(+) diff --git a/tokio/src/net/tcp/stream.rs b/tokio/src/net/tcp/stream.rs index 0b8529546c6..09045d9c665 100644 --- a/tokio/src/net/tcp/stream.rs +++ b/tokio/src/net/tcp/stream.rs @@ -1002,6 +1002,48 @@ impl TcpStream { .registration() .try_io(interest, || self.io.try_io(f)) } + + /// Reads or writes from the socket using a user-provided IO operation. + /// + /// The readiness of the socket is awaited and when the socket is ready, + /// the provided closure is called. The closure should attempt to perform + /// IO operation on the socket by manually calling the appropriate syscall. + /// If the operation fails because the socket is not actually ready, + /// then the closure should return a `WouldBlock` error, the readiness + /// flag is cleared and the socket readiness is awaited again. This loop + /// repeated until the closure returns an `Ok` or an error that doesn't + /// have the `WouldBlock` value. + /// + /// The closure should only return a `WouldBlock` error if it has performed + /// an IO operation on the socket that failed due to the socket not being + /// ready. Returning a `WouldBlock` error in any other situation will + /// incorrectly clear the readiness flag, which can cause the socket to + /// behave incorrectly. + /// + /// The closure should not perform the IO operation using any of the methods + /// defined on the Tokio `UdpSocket` type, as this will mess with the + /// readiness flag and can cause the socket to behave incorrectly. + /// + /// This method is not intended to be used with combined interests. + /// The closure should perform only one type of IO operation, so it should not + /// require more than one ready state. This method may panic or sleep forever + /// if it is called with a combined interest. + /// + /// Usually, [`readable()`], [`writable()`] or [`ready()`] is used with this function. + /// + /// [`readable()`]: UdpSocket::readable() + /// [`writable()`]: UdpSocket::writable() + /// [`ready()`]: UdpSocket::ready() + pub async fn async_io( + &self, + interest: Interest, + mut f: impl FnMut() -> io::Result, + ) -> io::Result { + self.io + .registration() + .async_io(interest, || self.io.try_io(&mut f) ) + .await + } /// Receives data on the socket from the remote address to which it is /// connected, without removing that data from the queue. On success, diff --git a/tokio/src/net/unix/datagram/socket.rs b/tokio/src/net/unix/datagram/socket.rs index 0f5dca421cf..8e455f67187 100644 --- a/tokio/src/net/unix/datagram/socket.rs +++ b/tokio/src/net/unix/datagram/socket.rs @@ -1252,6 +1252,48 @@ impl UnixDatagram { .registration() .try_io(interest, || self.io.try_io(f)) } + + /// Reads or writes from the socket using a user-provided IO operation. + /// + /// The readiness of the socket is awaited and when the socket is ready, + /// the provided closure is called. The closure should attempt to perform + /// IO operation on the socket by manually calling the appropriate syscall. + /// If the operation fails because the socket is not actually ready, + /// then the closure should return a `WouldBlock` error, the readiness + /// flag is cleared and the socket readiness is awaited again. This loop + /// repeated until the closure returns an `Ok` or an error that doesn't + /// have the `WouldBlock` value. + /// + /// The closure should only return a `WouldBlock` error if it has performed + /// an IO operation on the socket that failed due to the socket not being + /// ready. Returning a `WouldBlock` error in any other situation will + /// incorrectly clear the readiness flag, which can cause the socket to + /// behave incorrectly. + /// + /// The closure should not perform the IO operation using any of the methods + /// defined on the Tokio `UdpSocket` type, as this will mess with the + /// readiness flag and can cause the socket to behave incorrectly. + /// + /// This method is not intended to be used with combined interests. + /// The closure should perform only one type of IO operation, so it should not + /// require more than one ready state. This method may panic or sleep forever + /// if it is called with a combined interest. + /// + /// Usually, [`readable()`], [`writable()`] or [`ready()`] is used with this function. + /// + /// [`readable()`]: UdpSocket::readable() + /// [`writable()`]: UdpSocket::writable() + /// [`ready()`]: UdpSocket::ready() + pub async fn async_io( + &self, + interest: Interest, + mut f: impl FnMut() -> io::Result, + ) -> io::Result { + self.io + .registration() + .async_io(interest, || self.io.try_io(&mut f) ) + .await + } /// Returns the local address that this socket is bound to. /// diff --git a/tokio/src/net/unix/stream.rs b/tokio/src/net/unix/stream.rs index e9acbb68240..f0a7e37554c 100644 --- a/tokio/src/net/unix/stream.rs +++ b/tokio/src/net/unix/stream.rs @@ -699,6 +699,48 @@ impl UnixStream { .registration() .try_io(interest, || self.io.try_io(f)) } + + /// Reads or writes from the socket using a user-provided IO operation. + /// + /// The readiness of the socket is awaited and when the socket is ready, + /// the provided closure is called. The closure should attempt to perform + /// IO operation on the socket by manually calling the appropriate syscall. + /// If the operation fails because the socket is not actually ready, + /// then the closure should return a `WouldBlock` error, the readiness + /// flag is cleared and the socket readiness is awaited again. This loop + /// repeated until the closure returns an `Ok` or an error that doesn't + /// have the `WouldBlock` value. + /// + /// The closure should only return a `WouldBlock` error if it has performed + /// an IO operation on the socket that failed due to the socket not being + /// ready. Returning a `WouldBlock` error in any other situation will + /// incorrectly clear the readiness flag, which can cause the socket to + /// behave incorrectly. + /// + /// The closure should not perform the IO operation using any of the methods + /// defined on the Tokio `UdpSocket` type, as this will mess with the + /// readiness flag and can cause the socket to behave incorrectly. + /// + /// This method is not intended to be used with combined interests. + /// The closure should perform only one type of IO operation, so it should not + /// require more than one ready state. This method may panic or sleep forever + /// if it is called with a combined interest. + /// + /// Usually, [`readable()`], [`writable()`] or [`ready()`] is used with this function. + /// + /// [`readable()`]: UdpSocket::readable() + /// [`writable()`]: UdpSocket::writable() + /// [`ready()`]: UdpSocket::ready() + pub async fn async_io( + &self, + interest: Interest, + mut f: impl FnMut() -> io::Result, + ) -> io::Result { + self.io + .registration() + .async_io(interest, || self.io.try_io(&mut f) ) + .await + } /// Creates new `UnixStream` from a `std::os::unix::net::UnixStream`. /// diff --git a/tokio/src/net/windows/named_pipe.rs b/tokio/src/net/windows/named_pipe.rs index 3f7a5a4fe9d..477c1057714 100644 --- a/tokio/src/net/windows/named_pipe.rs +++ b/tokio/src/net/windows/named_pipe.rs @@ -845,6 +845,48 @@ impl NamedPipeServer { ) -> io::Result { self.io.registration().try_io(interest, f) } + + /// Reads or writes from the socket using a user-provided IO operation. + /// + /// The readiness of the socket is awaited and when the socket is ready, + /// the provided closure is called. The closure should attempt to perform + /// IO operation on the socket by manually calling the appropriate syscall. + /// If the operation fails because the socket is not actually ready, + /// then the closure should return a `WouldBlock` error, the readiness + /// flag is cleared and the socket readiness is awaited again. This loop + /// repeated until the closure returns an `Ok` or an error that doesn't + /// have the `WouldBlock` value. + /// + /// The closure should only return a `WouldBlock` error if it has performed + /// an IO operation on the socket that failed due to the socket not being + /// ready. Returning a `WouldBlock` error in any other situation will + /// incorrectly clear the readiness flag, which can cause the socket to + /// behave incorrectly. + /// + /// The closure should not perform the IO operation using any of the methods + /// defined on the Tokio `UdpSocket` type, as this will mess with the + /// readiness flag and can cause the socket to behave incorrectly. + /// + /// This method is not intended to be used with combined interests. + /// The closure should perform only one type of IO operation, so it should not + /// require more than one ready state. This method may panic or sleep forever + /// if it is called with a combined interest. + /// + /// Usually, [`readable()`], [`writable()`] or [`ready()`] is used with this function. + /// + /// [`readable()`]: UdpSocket::readable() + /// [`writable()`]: UdpSocket::writable() + /// [`ready()`]: UdpSocket::ready() + pub async fn async_io( + &self, + interest: Interest, + mut f: impl FnMut() -> io::Result, + ) -> io::Result { + self.io + .registration() + .async_io(interest, || self.io.try_io(&mut f) ) + .await + } } impl AsyncRead for NamedPipeServer { @@ -1589,6 +1631,48 @@ impl NamedPipeClient { ) -> io::Result { self.io.registration().try_io(interest, f) } + + /// Reads or writes from the socket using a user-provided IO operation. + /// + /// The readiness of the socket is awaited and when the socket is ready, + /// the provided closure is called. The closure should attempt to perform + /// IO operation on the socket by manually calling the appropriate syscall. + /// If the operation fails because the socket is not actually ready, + /// then the closure should return a `WouldBlock` error, the readiness + /// flag is cleared and the socket readiness is awaited again. This loop + /// repeated until the closure returns an `Ok` or an error that doesn't + /// have the `WouldBlock` value. + /// + /// The closure should only return a `WouldBlock` error if it has performed + /// an IO operation on the socket that failed due to the socket not being + /// ready. Returning a `WouldBlock` error in any other situation will + /// incorrectly clear the readiness flag, which can cause the socket to + /// behave incorrectly. + /// + /// The closure should not perform the IO operation using any of the methods + /// defined on the Tokio `UdpSocket` type, as this will mess with the + /// readiness flag and can cause the socket to behave incorrectly. + /// + /// This method is not intended to be used with combined interests. + /// The closure should perform only one type of IO operation, so it should not + /// require more than one ready state. This method may panic or sleep forever + /// if it is called with a combined interest. + /// + /// Usually, [`readable()`], [`writable()`] or [`ready()`] is used with this function. + /// + /// [`readable()`]: UdpSocket::readable() + /// [`writable()`]: UdpSocket::writable() + /// [`ready()`]: UdpSocket::ready() + pub async fn async_io( + &self, + interest: Interest, + mut f: impl FnMut() -> io::Result, + ) -> io::Result { + self.io + .registration() + .async_io(interest, || self.io.try_io(&mut f) ) + .await + } } impl AsyncRead for NamedPipeClient { From ae08934bdf3a0d688de83b6afd10f433e6961747 Mon Sep 17 00:00:00 2001 From: amab8901 Date: Tue, 28 Feb 2023 04:52:26 +0100 Subject: [PATCH 05/16] Add correct struct names into docs --- tokio/src/net/tcp/stream.rs | 8 ++++---- tokio/src/net/unix/datagram/socket.rs | 8 ++++---- tokio/src/net/unix/stream.rs | 8 ++++---- tokio/src/net/windows/named_pipe.rs | 16 ++++++++-------- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/tokio/src/net/tcp/stream.rs b/tokio/src/net/tcp/stream.rs index a99e6badad1..71aa2fab3eb 100644 --- a/tokio/src/net/tcp/stream.rs +++ b/tokio/src/net/tcp/stream.rs @@ -1034,7 +1034,7 @@ impl TcpStream { /// behave incorrectly. /// /// The closure should not perform the IO operation using any of the methods - /// defined on the Tokio `UdpSocket` type, as this will mess with the + /// defined on the Tokio `TcpStream` type, as this will mess with the /// readiness flag and can cause the socket to behave incorrectly. /// /// This method is not intended to be used with combined interests. @@ -1044,9 +1044,9 @@ impl TcpStream { /// /// Usually, [`readable()`], [`writable()`] or [`ready()`] is used with this function. /// - /// [`readable()`]: UdpSocket::readable() - /// [`writable()`]: UdpSocket::writable() - /// [`ready()`]: UdpSocket::ready() + /// [`readable()`]: TcpStream::readable() + /// [`writable()`]: TcpStream::writable() + /// [`ready()`]: TcpStream::ready() pub async fn async_io( &self, interest: Interest, diff --git a/tokio/src/net/unix/datagram/socket.rs b/tokio/src/net/unix/datagram/socket.rs index 7b56f45a0b9..811fb62eb31 100644 --- a/tokio/src/net/unix/datagram/socket.rs +++ b/tokio/src/net/unix/datagram/socket.rs @@ -1278,7 +1278,7 @@ impl UnixDatagram { /// behave incorrectly. /// /// The closure should not perform the IO operation using any of the methods - /// defined on the Tokio `UdpSocket` type, as this will mess with the + /// defined on the Tokio `UnixDatagram` type, as this will mess with the /// readiness flag and can cause the socket to behave incorrectly. /// /// This method is not intended to be used with combined interests. @@ -1288,9 +1288,9 @@ impl UnixDatagram { /// /// Usually, [`readable()`], [`writable()`] or [`ready()`] is used with this function. /// - /// [`readable()`]: UdpSocket::readable() - /// [`writable()`]: UdpSocket::writable() - /// [`ready()`]: UdpSocket::ready() + /// [`readable()`]: UnixDatagram::readable() + /// [`writable()`]: UnixDatagram::writable() + /// [`ready()`]: UnixDatagram::ready() pub async fn async_io( &self, interest: Interest, diff --git a/tokio/src/net/unix/stream.rs b/tokio/src/net/unix/stream.rs index 529f10f33d4..04f898274fa 100644 --- a/tokio/src/net/unix/stream.rs +++ b/tokio/src/net/unix/stream.rs @@ -724,7 +724,7 @@ impl UnixStream { /// behave incorrectly. /// /// The closure should not perform the IO operation using any of the methods - /// defined on the Tokio `UdpSocket` type, as this will mess with the + /// defined on the Tokio `UnixStream` type, as this will mess with the /// readiness flag and can cause the socket to behave incorrectly. /// /// This method is not intended to be used with combined interests. @@ -734,9 +734,9 @@ impl UnixStream { /// /// Usually, [`readable()`], [`writable()`] or [`ready()`] is used with this function. /// - /// [`readable()`]: UdpSocket::readable() - /// [`writable()`]: UdpSocket::writable() - /// [`ready()`]: UdpSocket::ready() + /// [`readable()`]: UnixStream::readable() + /// [`writable()`]: UnixStream::writable() + /// [`ready()`]: UnixStream::ready() pub async fn async_io( &self, interest: Interest, diff --git a/tokio/src/net/windows/named_pipe.rs b/tokio/src/net/windows/named_pipe.rs index 19325bfabad..5c857338577 100644 --- a/tokio/src/net/windows/named_pipe.rs +++ b/tokio/src/net/windows/named_pipe.rs @@ -870,7 +870,7 @@ impl NamedPipeServer { /// behave incorrectly. /// /// The closure should not perform the IO operation using any of the methods - /// defined on the Tokio `UdpSocket` type, as this will mess with the + /// defined on the Tokio `NamedPipeServer` type, as this will mess with the /// readiness flag and can cause the socket to behave incorrectly. /// /// This method is not intended to be used with combined interests. @@ -880,9 +880,9 @@ impl NamedPipeServer { /// /// Usually, [`readable()`], [`writable()`] or [`ready()`] is used with this function. /// - /// [`readable()`]: UdpSocket::readable() - /// [`writable()`]: UdpSocket::writable() - /// [`ready()`]: UdpSocket::ready() + /// [`readable()`]: NamedPipeServer::readable() + /// [`writable()`]: NamedPipeServer::writable() + /// [`ready()`]: NamedPipeServer::ready() pub async fn async_io( &self, interest: Interest, @@ -1662,7 +1662,7 @@ impl NamedPipeClient { /// behave incorrectly. /// /// The closure should not perform the IO operation using any of the methods - /// defined on the Tokio `UdpSocket` type, as this will mess with the + /// defined on the Tokio `NamedPipeClient` type, as this will mess with the /// readiness flag and can cause the socket to behave incorrectly. /// /// This method is not intended to be used with combined interests. @@ -1672,9 +1672,9 @@ impl NamedPipeClient { /// /// Usually, [`readable()`], [`writable()`] or [`ready()`] is used with this function. /// - /// [`readable()`]: UdpSocket::readable() - /// [`writable()`]: UdpSocket::writable() - /// [`ready()`]: UdpSocket::ready() + /// [`readable()`]: NamedPipeClient::readable() + /// [`writable()`]: NamedPipeClient::writable() + /// [`ready()`]: NamedPipeClient::ready() pub async fn async_io( &self, interest: Interest, From 7aea7000529519ad08bf6086615a01c82233efdd Mon Sep 17 00:00:00 2001 From: amab8901 Date: Tue, 28 Feb 2023 04:55:59 +0100 Subject: [PATCH 06/16] Remove inaccurate docs --- tokio/src/net/tcp/stream.rs | 6 ------ tokio/src/net/udp.rs | 6 ------ tokio/src/net/unix/datagram/socket.rs | 6 ------ tokio/src/net/unix/stream.rs | 6 ------ tokio/src/net/windows/named_pipe.rs | 12 ------------ 5 files changed, 36 deletions(-) diff --git a/tokio/src/net/tcp/stream.rs b/tokio/src/net/tcp/stream.rs index 71aa2fab3eb..62eb5b5e2e5 100644 --- a/tokio/src/net/tcp/stream.rs +++ b/tokio/src/net/tcp/stream.rs @@ -1041,12 +1041,6 @@ impl TcpStream { /// The closure should perform only one type of IO operation, so it should not /// require more than one ready state. This method may panic or sleep forever /// if it is called with a combined interest. - /// - /// Usually, [`readable()`], [`writable()`] or [`ready()`] is used with this function. - /// - /// [`readable()`]: TcpStream::readable() - /// [`writable()`]: TcpStream::writable() - /// [`ready()`]: TcpStream::ready() pub async fn async_io( &self, interest: Interest, diff --git a/tokio/src/net/udp.rs b/tokio/src/net/udp.rs index ff6878ededa..b97c5161092 100644 --- a/tokio/src/net/udp.rs +++ b/tokio/src/net/udp.rs @@ -1344,12 +1344,6 @@ impl UdpSocket { /// The closure should perform only one type of IO operation, so it should not /// require more than one ready state. This method may panic or sleep forever /// if it is called with a combined interest. - /// - /// Usually, [`readable()`], [`writable()`] or [`ready()`] is used with this function. - /// - /// [`readable()`]: UdpSocket::readable() - /// [`writable()`]: UdpSocket::writable() - /// [`ready()`]: UdpSocket::ready() pub async fn async_io( &self, interest: Interest, diff --git a/tokio/src/net/unix/datagram/socket.rs b/tokio/src/net/unix/datagram/socket.rs index 811fb62eb31..78dcb17c51f 100644 --- a/tokio/src/net/unix/datagram/socket.rs +++ b/tokio/src/net/unix/datagram/socket.rs @@ -1285,12 +1285,6 @@ impl UnixDatagram { /// The closure should perform only one type of IO operation, so it should not /// require more than one ready state. This method may panic or sleep forever /// if it is called with a combined interest. - /// - /// Usually, [`readable()`], [`writable()`] or [`ready()`] is used with this function. - /// - /// [`readable()`]: UnixDatagram::readable() - /// [`writable()`]: UnixDatagram::writable() - /// [`ready()`]: UnixDatagram::ready() pub async fn async_io( &self, interest: Interest, diff --git a/tokio/src/net/unix/stream.rs b/tokio/src/net/unix/stream.rs index 04f898274fa..4b6c28c21ff 100644 --- a/tokio/src/net/unix/stream.rs +++ b/tokio/src/net/unix/stream.rs @@ -731,12 +731,6 @@ impl UnixStream { /// The closure should perform only one type of IO operation, so it should not /// require more than one ready state. This method may panic or sleep forever /// if it is called with a combined interest. - /// - /// Usually, [`readable()`], [`writable()`] or [`ready()`] is used with this function. - /// - /// [`readable()`]: UnixStream::readable() - /// [`writable()`]: UnixStream::writable() - /// [`ready()`]: UnixStream::ready() pub async fn async_io( &self, interest: Interest, diff --git a/tokio/src/net/windows/named_pipe.rs b/tokio/src/net/windows/named_pipe.rs index 5c857338577..9abf965feb1 100644 --- a/tokio/src/net/windows/named_pipe.rs +++ b/tokio/src/net/windows/named_pipe.rs @@ -877,12 +877,6 @@ impl NamedPipeServer { /// The closure should perform only one type of IO operation, so it should not /// require more than one ready state. This method may panic or sleep forever /// if it is called with a combined interest. - /// - /// Usually, [`readable()`], [`writable()`] or [`ready()`] is used with this function. - /// - /// [`readable()`]: NamedPipeServer::readable() - /// [`writable()`]: NamedPipeServer::writable() - /// [`ready()`]: NamedPipeServer::ready() pub async fn async_io( &self, interest: Interest, @@ -1669,12 +1663,6 @@ impl NamedPipeClient { /// The closure should perform only one type of IO operation, so it should not /// require more than one ready state. This method may panic or sleep forever /// if it is called with a combined interest. - /// - /// Usually, [`readable()`], [`writable()`] or [`ready()`] is used with this function. - /// - /// [`readable()`]: NamedPipeClient::readable() - /// [`writable()`]: NamedPipeClient::writable() - /// [`ready()`]: NamedPipeClient::ready() pub async fn async_io( &self, interest: Interest, From ae1b8796ec8db5ebb4566f3c57085278e1cc9631 Mon Sep 17 00:00:00 2001 From: amab8901 Date: Tue, 28 Feb 2023 04:58:30 +0100 Subject: [PATCH 07/16] Replace socket with pipe in pipe docs --- tokio/src/net/windows/named_pipe.rs | 32 ++++++++++++++--------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/tokio/src/net/windows/named_pipe.rs b/tokio/src/net/windows/named_pipe.rs index 9abf965feb1..04bf33423ed 100644 --- a/tokio/src/net/windows/named_pipe.rs +++ b/tokio/src/net/windows/named_pipe.rs @@ -852,26 +852,26 @@ impl NamedPipeServer { self.io.registration().try_io(interest, f) } - /// Reads or writes from the socket using a user-provided IO operation. + /// Reads or writes from the pipe using a user-provided IO operation. /// - /// The readiness of the socket is awaited and when the socket is ready, + /// The readiness of the pipe is awaited and when the pipe is ready, /// the provided closure is called. The closure should attempt to perform - /// IO operation on the socket by manually calling the appropriate syscall. - /// If the operation fails because the socket is not actually ready, + /// IO operation on the pipe by manually calling the appropriate syscall. + /// If the operation fails because the pipe is not actually ready, /// then the closure should return a `WouldBlock` error, the readiness - /// flag is cleared and the socket readiness is awaited again. This loop + /// flag is cleared and the pipe readiness is awaited again. This loop /// repeated until the closure returns an `Ok` or an error that doesn't /// have the `WouldBlock` value. /// /// The closure should only return a `WouldBlock` error if it has performed - /// an IO operation on the socket that failed due to the socket not being + /// an IO operation on the pipe that failed due to the pipe not being /// ready. Returning a `WouldBlock` error in any other situation will - /// incorrectly clear the readiness flag, which can cause the socket to + /// incorrectly clear the readiness flag, which can cause the pipe to /// behave incorrectly. /// /// The closure should not perform the IO operation using any of the methods /// defined on the Tokio `NamedPipeServer` type, as this will mess with the - /// readiness flag and can cause the socket to behave incorrectly. + /// readiness flag and can cause the pipe to behave incorrectly. /// /// This method is not intended to be used with combined interests. /// The closure should perform only one type of IO operation, so it should not @@ -1638,26 +1638,26 @@ impl NamedPipeClient { self.io.registration().try_io(interest, f) } - /// Reads or writes from the socket using a user-provided IO operation. + /// Reads or writes from the pipe using a user-provided IO operation. /// - /// The readiness of the socket is awaited and when the socket is ready, + /// The readiness of the pipe is awaited and when the pipe is ready, /// the provided closure is called. The closure should attempt to perform - /// IO operation on the socket by manually calling the appropriate syscall. - /// If the operation fails because the socket is not actually ready, + /// IO operation on the pipe by manually calling the appropriate syscall. + /// If the operation fails because the pipe is not actually ready, /// then the closure should return a `WouldBlock` error, the readiness - /// flag is cleared and the socket readiness is awaited again. This loop + /// flag is cleared and the pipe readiness is awaited again. This loop /// repeated until the closure returns an `Ok` or an error that doesn't /// have the `WouldBlock` value. /// /// The closure should only return a `WouldBlock` error if it has performed - /// an IO operation on the socket that failed due to the socket not being + /// an IO operation on the pipe that failed due to the pipe not being /// ready. Returning a `WouldBlock` error in any other situation will - /// incorrectly clear the readiness flag, which can cause the socket to + /// incorrectly clear the readiness flag, which can cause the pipe to /// behave incorrectly. /// /// The closure should not perform the IO operation using any of the methods /// defined on the Tokio `NamedPipeClient` type, as this will mess with the - /// readiness flag and can cause the socket to behave incorrectly. + /// readiness flag and can cause the pipe to behave incorrectly. /// /// This method is not intended to be used with combined interests. /// The closure should perform only one type of IO operation, so it should not From 08818a7142546629981c4d1053c27221425e75c4 Mon Sep 17 00:00:00 2001 From: amab8901 Date: Tue, 28 Feb 2023 05:25:45 +0100 Subject: [PATCH 08/16] Improve word formulation in docs --- tokio/src/net/tcp/stream.rs | 8 ++++---- tokio/src/net/udp.rs | 8 ++++---- tokio/src/net/unix/datagram/socket.rs | 8 ++++---- tokio/src/net/unix/stream.rs | 8 ++++---- tokio/src/net/windows/named_pipe.rs | 16 ++++++++-------- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/tokio/src/net/tcp/stream.rs b/tokio/src/net/tcp/stream.rs index 62eb5b5e2e5..9c06646a24c 100644 --- a/tokio/src/net/tcp/stream.rs +++ b/tokio/src/net/tcp/stream.rs @@ -1022,10 +1022,10 @@ impl TcpStream { /// the provided closure is called. The closure should attempt to perform /// IO operation on the socket by manually calling the appropriate syscall. /// If the operation fails because the socket is not actually ready, - /// then the closure should return a `WouldBlock` error, the readiness - /// flag is cleared and the socket readiness is awaited again. This loop - /// repeated until the closure returns an `Ok` or an error that doesn't - /// have the `WouldBlock` value. + /// then the closure should return a `WouldBlock` error. In such case the + /// readiness flag is cleared and the socket readiness is awaited again. + /// This loop is repeated until the closure returns an `Ok` or an error + /// other than `WouldBlock`. /// /// The closure should only return a `WouldBlock` error if it has performed /// an IO operation on the socket that failed due to the socket not being diff --git a/tokio/src/net/udp.rs b/tokio/src/net/udp.rs index b97c5161092..f98569b7caa 100644 --- a/tokio/src/net/udp.rs +++ b/tokio/src/net/udp.rs @@ -1325,10 +1325,10 @@ impl UdpSocket { /// the provided closure is called. The closure should attempt to perform /// IO operation on the socket by manually calling the appropriate syscall. /// If the operation fails because the socket is not actually ready, - /// then the closure should return a `WouldBlock` error, the readiness - /// flag is cleared and the socket readiness is awaited again. This loop - /// repeated until the closure returns an `Ok` or an error that doesn't - /// have the `WouldBlock` value. + /// then the closure should return a `WouldBlock` error. In such case the + /// readiness flag is cleared and the socket readiness is awaited again. + /// This loop is repeated until the closure returns an `Ok` or an error + /// other than `WouldBlock`. /// /// The closure should only return a `WouldBlock` error if it has performed /// an IO operation on the socket that failed due to the socket not being diff --git a/tokio/src/net/unix/datagram/socket.rs b/tokio/src/net/unix/datagram/socket.rs index 78dcb17c51f..a19f6775afe 100644 --- a/tokio/src/net/unix/datagram/socket.rs +++ b/tokio/src/net/unix/datagram/socket.rs @@ -1266,10 +1266,10 @@ impl UnixDatagram { /// the provided closure is called. The closure should attempt to perform /// IO operation on the socket by manually calling the appropriate syscall. /// If the operation fails because the socket is not actually ready, - /// then the closure should return a `WouldBlock` error, the readiness - /// flag is cleared and the socket readiness is awaited again. This loop - /// repeated until the closure returns an `Ok` or an error that doesn't - /// have the `WouldBlock` value. + /// then the closure should return a `WouldBlock` error. In such case the + /// readiness flag is cleared and the socket readiness is awaited again. + /// This loop is repeated until the closure returns an `Ok` or an error + /// other than `WouldBlock`. /// /// The closure should only return a `WouldBlock` error if it has performed /// an IO operation on the socket that failed due to the socket not being diff --git a/tokio/src/net/unix/stream.rs b/tokio/src/net/unix/stream.rs index 4b6c28c21ff..2aecba09e05 100644 --- a/tokio/src/net/unix/stream.rs +++ b/tokio/src/net/unix/stream.rs @@ -712,10 +712,10 @@ impl UnixStream { /// the provided closure is called. The closure should attempt to perform /// IO operation on the socket by manually calling the appropriate syscall. /// If the operation fails because the socket is not actually ready, - /// then the closure should return a `WouldBlock` error, the readiness - /// flag is cleared and the socket readiness is awaited again. This loop - /// repeated until the closure returns an `Ok` or an error that doesn't - /// have the `WouldBlock` value. + /// then the closure should return a `WouldBlock` error. In such case the + /// readiness flag is cleared and the socket readiness is awaited again. + /// This loop is repeated until the closure returns an `Ok` or an error + /// other than `WouldBlock`. /// /// The closure should only return a `WouldBlock` error if it has performed /// an IO operation on the socket that failed due to the socket not being diff --git a/tokio/src/net/windows/named_pipe.rs b/tokio/src/net/windows/named_pipe.rs index 04bf33423ed..bad33141840 100644 --- a/tokio/src/net/windows/named_pipe.rs +++ b/tokio/src/net/windows/named_pipe.rs @@ -858,10 +858,10 @@ impl NamedPipeServer { /// the provided closure is called. The closure should attempt to perform /// IO operation on the pipe by manually calling the appropriate syscall. /// If the operation fails because the pipe is not actually ready, - /// then the closure should return a `WouldBlock` error, the readiness - /// flag is cleared and the pipe readiness is awaited again. This loop - /// repeated until the closure returns an `Ok` or an error that doesn't - /// have the `WouldBlock` value. + /// then the closure should return a `WouldBlock` error. In such case the + /// readiness flag is cleared and the pipe readiness is awaited again. + /// This loop is repeated until the closure returns an `Ok` or an error + /// other than `WouldBlock`. /// /// The closure should only return a `WouldBlock` error if it has performed /// an IO operation on the pipe that failed due to the pipe not being @@ -1644,10 +1644,10 @@ impl NamedPipeClient { /// the provided closure is called. The closure should attempt to perform /// IO operation on the pipe by manually calling the appropriate syscall. /// If the operation fails because the pipe is not actually ready, - /// then the closure should return a `WouldBlock` error, the readiness - /// flag is cleared and the pipe readiness is awaited again. This loop - /// repeated until the closure returns an `Ok` or an error that doesn't - /// have the `WouldBlock` value. + /// then the closure should return a `WouldBlock` error. In such case the + /// readiness flag is cleared and the pipe readiness is awaited again. + /// This loop is repeated until the closure returns an `Ok` or an error + /// other than `WouldBlock`. /// /// The closure should only return a `WouldBlock` error if it has performed /// an IO operation on the pipe that failed due to the pipe not being From 66a8f9a71f1391e688ed32525725b37aa2c5095d Mon Sep 17 00:00:00 2001 From: amab8901 Date: Tue, 28 Feb 2023 11:41:00 +0100 Subject: [PATCH 09/16] Apply rustfmt --- tokio/src/net/tcp/stream.rs | 6 +++--- tokio/src/net/udp.rs | 6 +++--- tokio/src/net/unix/datagram/socket.rs | 6 +++--- tokio/src/net/unix/stream.rs | 6 +++--- tokio/src/net/windows/named_pipe.rs | 18 ++++++------------ 5 files changed, 18 insertions(+), 24 deletions(-) diff --git a/tokio/src/net/tcp/stream.rs b/tokio/src/net/tcp/stream.rs index 9c06646a24c..04bad26cb8a 100644 --- a/tokio/src/net/tcp/stream.rs +++ b/tokio/src/net/tcp/stream.rs @@ -1042,13 +1042,13 @@ impl TcpStream { /// require more than one ready state. This method may panic or sleep forever /// if it is called with a combined interest. pub async fn async_io( - &self, - interest: Interest, + &self, + interest: Interest, mut f: impl FnMut() -> io::Result, ) -> io::Result { self.io .registration() - .async_io(interest, || self.io.try_io(&mut f) ) + .async_io(interest, || self.io.try_io(&mut f)) .await } diff --git a/tokio/src/net/udp.rs b/tokio/src/net/udp.rs index f98569b7caa..e3f982a7568 100644 --- a/tokio/src/net/udp.rs +++ b/tokio/src/net/udp.rs @@ -1345,13 +1345,13 @@ impl UdpSocket { /// require more than one ready state. This method may panic or sleep forever /// if it is called with a combined interest. pub async fn async_io( - &self, - interest: Interest, + &self, + interest: Interest, mut f: impl FnMut() -> io::Result, ) -> io::Result { self.io .registration() - .async_io(interest, || self.io.try_io(&mut f) ) + .async_io(interest, || self.io.try_io(&mut f)) .await } diff --git a/tokio/src/net/unix/datagram/socket.rs b/tokio/src/net/unix/datagram/socket.rs index a19f6775afe..701511a28a4 100644 --- a/tokio/src/net/unix/datagram/socket.rs +++ b/tokio/src/net/unix/datagram/socket.rs @@ -1286,13 +1286,13 @@ impl UnixDatagram { /// require more than one ready state. This method may panic or sleep forever /// if it is called with a combined interest. pub async fn async_io( - &self, - interest: Interest, + &self, + interest: Interest, mut f: impl FnMut() -> io::Result, ) -> io::Result { self.io .registration() - .async_io(interest, || self.io.try_io(&mut f) ) + .async_io(interest, || self.io.try_io(&mut f)) .await } diff --git a/tokio/src/net/unix/stream.rs b/tokio/src/net/unix/stream.rs index 2aecba09e05..cb3fcafd53f 100644 --- a/tokio/src/net/unix/stream.rs +++ b/tokio/src/net/unix/stream.rs @@ -732,13 +732,13 @@ impl UnixStream { /// require more than one ready state. This method may panic or sleep forever /// if it is called with a combined interest. pub async fn async_io( - &self, - interest: Interest, + &self, + interest: Interest, mut f: impl FnMut() -> io::Result, ) -> io::Result { self.io .registration() - .async_io(interest, || self.io.try_io(&mut f) ) + .async_io(interest, || self.io.try_io(&mut f)) .await } diff --git a/tokio/src/net/windows/named_pipe.rs b/tokio/src/net/windows/named_pipe.rs index bad33141840..4611b606fd8 100644 --- a/tokio/src/net/windows/named_pipe.rs +++ b/tokio/src/net/windows/named_pipe.rs @@ -878,14 +878,11 @@ impl NamedPipeServer { /// require more than one ready state. This method may panic or sleep forever /// if it is called with a combined interest. pub async fn async_io( - &self, - interest: Interest, + &self, + interest: Interest, mut f: impl FnMut() -> io::Result, ) -> io::Result { - self.io - .registration() - .async_io(interest, || self.io.try_io(&mut f) ) - .await + self.io.registration().async_io(interest, f).await } } @@ -1664,14 +1661,11 @@ impl NamedPipeClient { /// require more than one ready state. This method may panic or sleep forever /// if it is called with a combined interest. pub async fn async_io( - &self, - interest: Interest, + &self, + interest: Interest, mut f: impl FnMut() -> io::Result, ) -> io::Result { - self.io - .registration() - .async_io(interest, || self.io.try_io(&mut f) ) - .await + self.io.registration().async_io(interest, || f).await } } From af4edf714006f6e5c9d20e09d0a401722dbfb56f Mon Sep 17 00:00:00 2001 From: amab8901 Date: Tue, 28 Feb 2023 11:50:09 +0100 Subject: [PATCH 10/16] Fix CI error --- tokio/src/net/windows/named_pipe.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tokio/src/net/windows/named_pipe.rs b/tokio/src/net/windows/named_pipe.rs index 4611b606fd8..2bc15513bc9 100644 --- a/tokio/src/net/windows/named_pipe.rs +++ b/tokio/src/net/windows/named_pipe.rs @@ -882,7 +882,7 @@ impl NamedPipeServer { interest: Interest, mut f: impl FnMut() -> io::Result, ) -> io::Result { - self.io.registration().async_io(interest, f).await + self.io.registration().async_io(interest, f()).await } } @@ -1632,7 +1632,7 @@ impl NamedPipeClient { interest: Interest, f: impl FnOnce() -> io::Result, ) -> io::Result { - self.io.registration().try_io(interest, f) + self.io.registration().try_io(interest, f()) } /// Reads or writes from the pipe using a user-provided IO operation. @@ -1665,7 +1665,7 @@ impl NamedPipeClient { interest: Interest, mut f: impl FnMut() -> io::Result, ) -> io::Result { - self.io.registration().async_io(interest, || f).await + self.io.registration().async_io(interest, || f()).await } } From 6058759195daa22c9f270bf0c69e7a8818c7a1ef Mon Sep 17 00:00:00 2001 From: amab8901 Date: Mon, 6 Mar 2023 09:01:55 +0100 Subject: [PATCH 11/16] Stop calling f --- tokio/src/net/windows/named_pipe.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tokio/src/net/windows/named_pipe.rs b/tokio/src/net/windows/named_pipe.rs index 2bc15513bc9..96d6f0aa46d 100644 --- a/tokio/src/net/windows/named_pipe.rs +++ b/tokio/src/net/windows/named_pipe.rs @@ -882,7 +882,7 @@ impl NamedPipeServer { interest: Interest, mut f: impl FnMut() -> io::Result, ) -> io::Result { - self.io.registration().async_io(interest, f()).await + self.io.registration().async_io(interest, f).await } } From fe905ff39f9a4744e79ab9dbd024f66e24edef83 Mon Sep 17 00:00:00 2001 From: amab8901 Date: Mon, 6 Mar 2023 10:42:50 +0100 Subject: [PATCH 12/16] Stop calling f --- tokio/src/net/windows/named_pipe.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tokio/src/net/windows/named_pipe.rs b/tokio/src/net/windows/named_pipe.rs index 96d6f0aa46d..60cb69a1471 100644 --- a/tokio/src/net/windows/named_pipe.rs +++ b/tokio/src/net/windows/named_pipe.rs @@ -1632,7 +1632,7 @@ impl NamedPipeClient { interest: Interest, f: impl FnOnce() -> io::Result, ) -> io::Result { - self.io.registration().try_io(interest, f()) + self.io.registration().try_io(interest, f) } /// Reads or writes from the pipe using a user-provided IO operation. From f5841711809f7c9b383dc56ac3b2df9f7b3f9396 Mon Sep 17 00:00:00 2001 From: amab8901 Date: Mon, 6 Mar 2023 10:48:52 +0100 Subject: [PATCH 13/16] Make f immutable --- tokio/src/net/windows/named_pipe.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tokio/src/net/windows/named_pipe.rs b/tokio/src/net/windows/named_pipe.rs index 60cb69a1471..5445e3e26fb 100644 --- a/tokio/src/net/windows/named_pipe.rs +++ b/tokio/src/net/windows/named_pipe.rs @@ -880,7 +880,7 @@ impl NamedPipeServer { pub async fn async_io( &self, interest: Interest, - mut f: impl FnMut() -> io::Result, + f: impl FnMut() -> io::Result, ) -> io::Result { self.io.registration().async_io(interest, f).await } From 769976772f9d4659f51bd14bf69eedf7b1c36082 Mon Sep 17 00:00:00 2001 From: amab8901 Date: Mon, 6 Mar 2023 11:19:45 +0100 Subject: [PATCH 14/16] Fix fmt --- tokio/src/net/tcp/stream.rs | 2 +- tokio/src/net/udp.rs | 2 +- tokio/src/net/unix/datagram/socket.rs | 2 +- tokio/src/net/unix/stream.rs | 2 +- tokio/src/net/windows/named_pipe.rs | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tokio/src/net/tcp/stream.rs b/tokio/src/net/tcp/stream.rs index 04bad26cb8a..3b5acc73307 100644 --- a/tokio/src/net/tcp/stream.rs +++ b/tokio/src/net/tcp/stream.rs @@ -1015,7 +1015,7 @@ impl TcpStream { .registration() .try_io(interest, || self.io.try_io(f)) } - + /// Reads or writes from the socket using a user-provided IO operation. /// /// The readiness of the socket is awaited and when the socket is ready, diff --git a/tokio/src/net/udp.rs b/tokio/src/net/udp.rs index e3f982a7568..734361e040a 100644 --- a/tokio/src/net/udp.rs +++ b/tokio/src/net/udp.rs @@ -1318,7 +1318,7 @@ impl UdpSocket { .registration() .try_io(interest, || self.io.try_io(f)) } - + /// Reads or writes from the socket using a user-provided IO operation. /// /// The readiness of the socket is awaited and when the socket is ready, diff --git a/tokio/src/net/unix/datagram/socket.rs b/tokio/src/net/unix/datagram/socket.rs index 701511a28a4..93c7674db95 100644 --- a/tokio/src/net/unix/datagram/socket.rs +++ b/tokio/src/net/unix/datagram/socket.rs @@ -1259,7 +1259,7 @@ impl UnixDatagram { .registration() .try_io(interest, || self.io.try_io(f)) } - + /// Reads or writes from the socket using a user-provided IO operation. /// /// The readiness of the socket is awaited and when the socket is ready, diff --git a/tokio/src/net/unix/stream.rs b/tokio/src/net/unix/stream.rs index cb3fcafd53f..9de70472b41 100644 --- a/tokio/src/net/unix/stream.rs +++ b/tokio/src/net/unix/stream.rs @@ -705,7 +705,7 @@ impl UnixStream { .registration() .try_io(interest, || self.io.try_io(f)) } - + /// Reads or writes from the socket using a user-provided IO operation. /// /// The readiness of the socket is awaited and when the socket is ready, diff --git a/tokio/src/net/windows/named_pipe.rs b/tokio/src/net/windows/named_pipe.rs index 5445e3e26fb..5e3bcca3345 100644 --- a/tokio/src/net/windows/named_pipe.rs +++ b/tokio/src/net/windows/named_pipe.rs @@ -851,7 +851,7 @@ impl NamedPipeServer { ) -> io::Result { self.io.registration().try_io(interest, f) } - + /// Reads or writes from the pipe using a user-provided IO operation. /// /// The readiness of the pipe is awaited and when the pipe is ready, @@ -1634,7 +1634,7 @@ impl NamedPipeClient { ) -> io::Result { self.io.registration().try_io(interest, f) } - + /// Reads or writes from the pipe using a user-provided IO operation. /// /// The readiness of the pipe is awaited and when the pipe is ready, From f2345af56b8933b76bb5832362938ce456170bb5 Mon Sep 17 00:00:00 2001 From: Alice Ryhl Date: Thu, 9 Mar 2023 10:36:20 +0100 Subject: [PATCH 15/16] Make named pipe implementations consistent Both `f` and `|| f()` would work, but I think it makes more sense to do the same in both places. --- tokio/src/net/windows/named_pipe.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tokio/src/net/windows/named_pipe.rs b/tokio/src/net/windows/named_pipe.rs index 5e3bcca3345..2d732509b48 100644 --- a/tokio/src/net/windows/named_pipe.rs +++ b/tokio/src/net/windows/named_pipe.rs @@ -1665,7 +1665,7 @@ impl NamedPipeClient { interest: Interest, mut f: impl FnMut() -> io::Result, ) -> io::Result { - self.io.registration().async_io(interest, || f()).await + self.io.registration().async_io(interest, f).await } } From 09bcc3e59a96090e71e2499b624f9ac4de35eb10 Mon Sep 17 00:00:00 2001 From: Alice Ryhl Date: Thu, 9 Mar 2023 10:43:38 +0100 Subject: [PATCH 16/16] fix oops --- tokio/src/net/windows/named_pipe.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tokio/src/net/windows/named_pipe.rs b/tokio/src/net/windows/named_pipe.rs index 2d732509b48..5f6cba1c9d8 100644 --- a/tokio/src/net/windows/named_pipe.rs +++ b/tokio/src/net/windows/named_pipe.rs @@ -1663,7 +1663,7 @@ impl NamedPipeClient { pub async fn async_io( &self, interest: Interest, - mut f: impl FnMut() -> io::Result, + f: impl FnMut() -> io::Result, ) -> io::Result { self.io.registration().async_io(interest, f).await }