diff --git a/embassy-net/src/tcp.rs b/embassy-net/src/tcp.rs index dcfb5c96e..72b0677b4 100644 --- a/embassy-net/src/tcp.rs +++ b/embassy-net/src/tcp.rs @@ -547,6 +547,12 @@ mod embedded_io_impls { } } + impl<'d> embedded_io_async::ReadReady for TcpSocket<'d> { + fn read_ready(&mut self) -> Result { + Ok(self.io.with(|s, _| s.may_recv())) + } + } + impl<'d> embedded_io_async::Write for TcpSocket<'d> { async fn write(&mut self, buf: &[u8]) -> Result { self.io.write(buf).await @@ -557,6 +563,12 @@ mod embedded_io_impls { } } + impl<'d> embedded_io_async::WriteReady for TcpSocket<'d> { + fn write_ready(&mut self) -> Result { + Ok(self.io.with(|s, _| s.may_send())) + } + } + impl<'d> embedded_io_async::ErrorType for TcpReader<'d> { type Error = Error; } @@ -567,6 +579,12 @@ mod embedded_io_impls { } } + impl<'d> embedded_io_async::ReadReady for TcpReader<'d> { + fn read_ready(&mut self) -> Result { + Ok(self.io.with(|s, _| s.may_recv())) + } + } + impl<'d> embedded_io_async::ErrorType for TcpWriter<'d> { type Error = Error; } @@ -580,6 +598,12 @@ mod embedded_io_impls { self.io.flush().await } } + + impl<'d> embedded_io_async::WriteReady for TcpWriter<'d> { + fn write_ready(&mut self) -> Result { + Ok(self.io.with(|s, _| s.may_send())) + } + } } /// TCP client compatible with `embedded-nal-async` traits.