diff options
Diffstat (limited to 'embassy-net/src')
| -rw-r--r-- | embassy-net/src/tcp.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/embassy-net/src/tcp.rs b/embassy-net/src/tcp.rs index a00ced8f4..150b4b36b 100644 --- a/embassy-net/src/tcp.rs +++ b/embassy-net/src/tcp.rs | |||
| @@ -73,6 +73,16 @@ pub struct TcpWriter<'a> { | |||
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | impl<'a> TcpReader<'a> { | 75 | impl<'a> TcpReader<'a> { |
| 76 | /// Wait until the socket becomes readable. | ||
| 77 | /// | ||
| 78 | /// A socket becomes readable when the receive half of the full-duplex connection is open | ||
| 79 | /// (see [`may_recv()`](TcpSocket::may_recv)), and there is some pending data in the receive buffer. | ||
| 80 | /// | ||
| 81 | /// This is the equivalent of [read](#method.read), without buffering any data. | ||
| 82 | pub async fn wait_read_ready(&self) { | ||
| 83 | poll_fn(move |cx| self.io.poll_read_ready(cx)).await | ||
| 84 | } | ||
| 85 | |||
| 76 | /// Read data from the socket. | 86 | /// Read data from the socket. |
| 77 | /// | 87 | /// |
| 78 | /// Returns how many bytes were read, or an error. If no data is available, it waits | 88 | /// Returns how many bytes were read, or an error. If no data is available, it waits |
| @@ -115,6 +125,16 @@ impl<'a> TcpReader<'a> { | |||
| 115 | } | 125 | } |
| 116 | 126 | ||
| 117 | impl<'a> TcpWriter<'a> { | 127 | impl<'a> TcpWriter<'a> { |
| 128 | /// Wait until the socket becomes writable. | ||
| 129 | /// | ||
| 130 | /// A socket becomes writable when the transmit half of the full-duplex connection is open | ||
| 131 | /// (see [`may_send()`](TcpSocket::may_send)), and the transmit buffer is not full. | ||
| 132 | /// | ||
| 133 | /// This is the equivalent of [write](#method.write), without sending any data. | ||
| 134 | pub async fn wait_write_ready(&self) { | ||
| 135 | poll_fn(move |cx| self.io.poll_write_ready(cx)).await | ||
| 136 | } | ||
| 137 | |||
| 118 | /// Write data to the socket. | 138 | /// Write data to the socket. |
| 119 | /// | 139 | /// |
| 120 | /// Returns how many bytes were written, or an error. If the socket is not ready to | 140 | /// Returns how many bytes were written, or an error. If the socket is not ready to |
