aboutsummaryrefslogtreecommitdiff
path: root/embassy-net/src/raw.rs
diff options
context:
space:
mode:
authorDániel Buga <[email protected]>2024-12-30 12:13:13 +0100
committerDániel Buga <[email protected]>2024-12-30 12:13:13 +0100
commit44217aa0924e7590aa0afabdf17babd5c2ea5b82 (patch)
treee42f5d02f9b560610b870d802cf390518180c3c6 /embassy-net/src/raw.rs
parenta4f8fddd696ca2e3705827ba4b3806cbadcb3134 (diff)
Desugar some async fns
Diffstat (limited to 'embassy-net/src/raw.rs')
-rw-r--r--embassy-net/src/raw.rs19
1 files changed, 9 insertions, 10 deletions
diff --git a/embassy-net/src/raw.rs b/embassy-net/src/raw.rs
index a88bcc458..c9f753f13 100644
--- a/embassy-net/src/raw.rs
+++ b/embassy-net/src/raw.rs
@@ -1,6 +1,6 @@
1//! Raw sockets. 1//! Raw sockets.
2 2
3use core::future::poll_fn; 3use core::future::{poll_fn, Future};
4use core::mem; 4use core::mem;
5use core::task::{Context, Poll}; 5use core::task::{Context, Poll};
6 6
@@ -66,8 +66,8 @@ impl<'a> RawSocket<'a> {
66 /// 66 ///
67 /// A socket is readable when a packet has been received, or when there are queued packets in 67 /// A socket is readable when a packet has been received, or when there are queued packets in
68 /// the buffer. 68 /// the buffer.
69 pub async fn wait_recv_ready(&self) { 69 pub fn wait_recv_ready(&self) -> impl Future<Output = ()> + '_ {
70 poll_fn(move |cx| self.poll_recv_ready(cx)).await 70 poll_fn(move |cx| self.poll_recv_ready(cx))
71 } 71 }
72 72
73 /// Receive a datagram. 73 /// Receive a datagram.
@@ -115,8 +115,8 @@ impl<'a> RawSocket<'a> {
115 /// 115 ///
116 /// A socket becomes writable when there is space in the buffer, from initial memory or after 116 /// A socket becomes writable when there is space in the buffer, from initial memory or after
117 /// dispatching datagrams on a full buffer. 117 /// dispatching datagrams on a full buffer.
118 pub async fn wait_send_ready(&self) { 118 pub fn wait_send_ready(&self) -> impl Future<Output = ()> + '_ {
119 poll_fn(move |cx| self.poll_send_ready(cx)).await 119 poll_fn(move |cx| self.poll_send_ready(cx))
120 } 120 }
121 121
122 /// Wait until a datagram can be sent. 122 /// Wait until a datagram can be sent.
@@ -141,8 +141,8 @@ impl<'a> RawSocket<'a> {
141 /// Send a datagram. 141 /// Send a datagram.
142 /// 142 ///
143 /// This method will wait until the datagram has been sent.` 143 /// This method will wait until the datagram has been sent.`
144 pub async fn send(&self, buf: &[u8]) { 144 pub fn send<'s>(&'s self, buf: &'s [u8]) -> impl Future<Output = ()> + 's {
145 poll_fn(move |cx| self.poll_send(buf, cx)).await 145 poll_fn(|cx| self.poll_send(buf, cx))
146 } 146 }
147 147
148 /// Send a datagram. 148 /// Send a datagram.
@@ -165,8 +165,8 @@ impl<'a> RawSocket<'a> {
165 /// Flush the socket. 165 /// Flush the socket.
166 /// 166 ///
167 /// This method will wait until the socket is flushed. 167 /// This method will wait until the socket is flushed.
168 pub async fn flush(&mut self) { 168 pub fn flush(&mut self) -> impl Future<Output = ()> + '_ {
169 poll_fn(move |cx| { 169 poll_fn(|cx| {
170 self.with_mut(|s, _| { 170 self.with_mut(|s, _| {
171 if s.send_queue() == 0 { 171 if s.send_queue() == 0 {
172 Poll::Ready(()) 172 Poll::Ready(())
@@ -176,7 +176,6 @@ impl<'a> RawSocket<'a> {
176 } 176 }
177 }) 177 })
178 }) 178 })
179 .await
180 } 179 }
181} 180}
182 181