Add functions to check if the UDP socket buffers are empty or not.
parent
3b18727032
commit
f01ce30466
|
@ -133,6 +133,11 @@ impl<'a, 'b> UdpSocket<'a, 'b> {
|
|||
self.endpoint = endpoint.into()
|
||||
}
|
||||
|
||||
/// Check whether the transmit buffer is full.
|
||||
pub fn can_send(&self) -> bool {
|
||||
!self.tx_buffer.full()
|
||||
}
|
||||
|
||||
/// Enqueue a packet to be sent to a given remote endpoint, and return a pointer
|
||||
/// to its payload.
|
||||
///
|
||||
|
@ -155,6 +160,11 @@ impl<'a, 'b> UdpSocket<'a, 'b> {
|
|||
Ok(buffer.copy_from_slice(data))
|
||||
}
|
||||
|
||||
/// Check whether the receive buffer is full.
|
||||
pub fn can_recv(&self) -> bool {
|
||||
!self.rx_buffer.empty()
|
||||
}
|
||||
|
||||
/// Dequeue a packet received from a remote endpoint, and return the endpoint as well
|
||||
/// as a pointer to the payload.
|
||||
///
|
||||
|
|
Loading…
Reference in New Issue