- use with
- rename to Truncated to `PacketTooLarge`
This commit is contained in:
parent
2fe299cc53
commit
c0d14a145c
@ -30,7 +30,7 @@ pub enum SendError {
|
|||||||
/// Socket not bound to an outgoing port.
|
/// Socket not bound to an outgoing port.
|
||||||
SocketNotBound,
|
SocketNotBound,
|
||||||
/// There is not enough transmit buffer capacity to ever send this packet.
|
/// There is not enough transmit buffer capacity to ever send this packet.
|
||||||
Truncated,
|
PacketTooLarge,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Error returned by [`UdpSocket::recv_from`].
|
/// Error returned by [`UdpSocket::recv_from`].
|
||||||
@ -252,11 +252,9 @@ impl<'a> UdpSocket<'a> {
|
|||||||
T: Into<UdpMetadata>,
|
T: Into<UdpMetadata>,
|
||||||
{
|
{
|
||||||
// Don't need to wake waker in `with_mut` if the buffer will never fit the udp tx_buffer.
|
// 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
|
let send_capacity_too_small = self.with(|s, _| s.payload_send_capacity() < buf.len());
|
||||||
.stack
|
|
||||||
.with(|i| i.sockets.get::<udp::Socket>(self.handle).payload_send_capacity() < buf.len());
|
|
||||||
if send_capacity_too_small {
|
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) {
|
self.with_mut(|s, _| match s.send_slice(buf, remote_endpoint) {
|
||||||
@ -291,11 +289,9 @@ impl<'a> UdpSocket<'a> {
|
|||||||
F: FnOnce(&mut [u8]) -> R,
|
F: FnOnce(&mut [u8]) -> R,
|
||||||
{
|
{
|
||||||
// Don't need to wake waker in `with_mut` if the buffer will never fit the udp tx_buffer.
|
// 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
|
let send_capacity_too_small = self.with(|s, _| s.payload_send_capacity() < size);
|
||||||
.stack
|
|
||||||
.with(|i| i.sockets.get::<udp::Socket>(self.handle).payload_send_capacity() < size);
|
|
||||||
if send_capacity_too_small {
|
if send_capacity_too_small {
|
||||||
return Err(SendError::Truncated);
|
return Err(SendError::PacketTooLarge);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut f = Some(f);
|
let mut f = Some(f);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user