Add functions to check if the UDP socket buffers are empty or not.

v0.7.x
whitequark 2017-01-11 06:33:51 +00:00
parent 3b18727032
commit f01ce30466
1 changed files with 10 additions and 0 deletions

View File

@ -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.
///