diff options
| author | Easyoakland <[email protected]> | 2025-01-26 15:51:31 -0700 |
|---|---|---|
| committer | Easyoakland <[email protected]> | 2025-01-26 15:51:31 -0700 |
| commit | c0d14a145c901126a548a77026ef2ef0d6e79738 (patch) | |
| tree | ce51be86e19a7d290f0005c217d00c9bf69d4893 /embassy-net/src | |
| parent | 2fe299cc538c28711fd838b5f2c3da6143a7335e (diff) | |
- use `with`
- rename to Truncated to `PacketTooLarge`
Diffstat (limited to 'embassy-net/src')
| -rw-r--r-- | embassy-net/src/udp.rs | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/embassy-net/src/udp.rs b/embassy-net/src/udp.rs index 7baa89ea0..eca3980b9 100644 --- a/embassy-net/src/udp.rs +++ b/embassy-net/src/udp.rs | |||
| @@ -30,7 +30,7 @@ pub enum SendError { | |||
| 30 | /// Socket not bound to an outgoing port. | 30 | /// Socket not bound to an outgoing port. |
| 31 | SocketNotBound, | 31 | SocketNotBound, |
| 32 | /// There is not enough transmit buffer capacity to ever send this packet. | 32 | /// There is not enough transmit buffer capacity to ever send this packet. |
| 33 | Truncated, | 33 | PacketTooLarge, |
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | /// Error returned by [`UdpSocket::recv_from`]. | 36 | /// Error returned by [`UdpSocket::recv_from`]. |
| @@ -252,11 +252,9 @@ impl<'a> UdpSocket<'a> { | |||
| 252 | T: Into<UdpMetadata>, | 252 | T: Into<UdpMetadata>, |
| 253 | { | 253 | { |
| 254 | // Don't need to wake waker in `with_mut` if the buffer will never fit the udp tx_buffer. | 254 | // Don't need to wake waker in `with_mut` if the buffer will never fit the udp tx_buffer. |
| 255 | let send_capacity_too_small = self | 255 | let send_capacity_too_small = self.with(|s, _| s.payload_send_capacity() < buf.len()); |
| 256 | .stack | ||
| 257 | .with(|i| i.sockets.get::<udp::Socket>(self.handle).payload_send_capacity() < buf.len()); | ||
| 258 | if send_capacity_too_small { | 256 | if send_capacity_too_small { |
| 259 | return Poll::Ready(Err(SendError::Truncated)); | 257 | return Poll::Ready(Err(SendError::PacketTooLarge)); |
| 260 | } | 258 | } |
| 261 | 259 | ||
| 262 | self.with_mut(|s, _| match s.send_slice(buf, remote_endpoint) { | 260 | self.with_mut(|s, _| match s.send_slice(buf, remote_endpoint) { |
| @@ -291,11 +289,9 @@ impl<'a> UdpSocket<'a> { | |||
| 291 | F: FnOnce(&mut [u8]) -> R, | 289 | F: FnOnce(&mut [u8]) -> R, |
| 292 | { | 290 | { |
| 293 | // Don't need to wake waker in `with_mut` if the buffer will never fit the udp tx_buffer. | 291 | // Don't need to wake waker in `with_mut` if the buffer will never fit the udp tx_buffer. |
| 294 | let send_capacity_too_small = self | 292 | let send_capacity_too_small = self.with(|s, _| s.payload_send_capacity() < size); |
| 295 | .stack | ||
| 296 | .with(|i| i.sockets.get::<udp::Socket>(self.handle).payload_send_capacity() < size); | ||
| 297 | if send_capacity_too_small { | 293 | if send_capacity_too_small { |
| 298 | return Err(SendError::Truncated); | 294 | return Err(SendError::PacketTooLarge); |
| 299 | } | 295 | } |
| 300 | 296 | ||
| 301 | let mut f = Some(f); | 297 | let mut f = Some(f); |
