From c0d14a145c901126a548a77026ef2ef0d6e79738 Mon Sep 17 00:00:00 2001 From: Easyoakland <97992568+Easyoakland@users.noreply.github.com> Date: Sun, 26 Jan 2025 15:51:31 -0700 Subject: [PATCH] - use `with` - rename to Truncated to `PacketTooLarge` --- embassy-net/src/udp.rs | 14 +++++--------- 1 file 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 { /// Socket not bound to an outgoing port. SocketNotBound, /// There is not enough transmit buffer capacity to ever send this packet. - Truncated, + PacketTooLarge, } /// Error returned by [`UdpSocket::recv_from`]. @@ -252,11 +252,9 @@ impl<'a> UdpSocket<'a> { T: Into, { // Don't need to wake waker in `with_mut` if the buffer will never fit the udp tx_buffer. - let send_capacity_too_small = self - .stack - .with(|i| i.sockets.get::(self.handle).payload_send_capacity() < buf.len()); + let send_capacity_too_small = self.with(|s, _| s.payload_send_capacity() < buf.len()); if send_capacity_too_small { - return Poll::Ready(Err(SendError::Truncated)); + return Poll::Ready(Err(SendError::PacketTooLarge)); } self.with_mut(|s, _| match s.send_slice(buf, remote_endpoint) { @@ -291,11 +289,9 @@ impl<'a> UdpSocket<'a> { F: FnOnce(&mut [u8]) -> R, { // Don't need to wake waker in `with_mut` if the buffer will never fit the udp tx_buffer. - let send_capacity_too_small = self - .stack - .with(|i| i.sockets.get::(self.handle).payload_send_capacity() < size); + let send_capacity_too_small = self.with(|s, _| s.payload_send_capacity() < size); if send_capacity_too_small { - return Err(SendError::Truncated); + return Err(SendError::PacketTooLarge); } let mut f = Some(f);