Merge pull request #3050 from ant32/queue

add send_queue and recv_queue to embassy-net
This commit is contained in:
Dario Nieuwenhuis 2024-06-05 22:02:02 +00:00 committed by GitHub
commit 72a5523c64
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -98,6 +98,13 @@ impl<'a> TcpReader<'a> {
pub fn recv_capacity(&self) -> usize {
self.io.recv_capacity()
}
/// Return the amount of octets queued in the receive buffer. This value can be larger than
/// the slice read by the next `recv` or `peek` call because it includes all queued octets,
/// and not only the octets that may be returned as a contiguous slice.
pub fn recv_queue(&self) -> usize {
self.io.recv_queue()
}
}
impl<'a> TcpWriter<'a> {
@ -132,6 +139,11 @@ impl<'a> TcpWriter<'a> {
pub fn send_capacity(&self) -> usize {
self.io.send_capacity()
}
/// Return the amount of octets queued in the transmit buffer.
pub fn send_queue(&self) -> usize {
self.io.send_queue()
}
}
impl<'a> TcpSocket<'a> {
@ -163,6 +175,18 @@ impl<'a> TcpSocket<'a> {
self.io.send_capacity()
}
/// Return the amount of octets queued in the transmit buffer.
pub fn send_queue(&self) -> usize {
self.io.send_queue()
}
/// Return the amount of octets queued in the receive buffer. This value can be larger than
/// the slice read by the next `recv` or `peek` call because it includes all queued octets,
/// and not only the octets that may be returned as a contiguous slice.
pub fn recv_queue(&self) -> usize {
self.io.recv_queue()
}
/// Call `f` with the largest contiguous slice of octets in the transmit buffer,
/// and enqueue the amount of elements returned by `f`.
///
@ -519,6 +543,14 @@ impl<'d> TcpIo<'d> {
fn send_capacity(&self) -> usize {
self.with(|s, _| s.send_capacity())
}
fn send_queue(&self) -> usize {
self.with(|s, _| s.send_queue())
}
fn recv_queue(&self) -> usize {
self.with(|s, _| s.recv_queue())
}
}
mod embedded_io_impls {