diff --git a/embassy-net/src/tcp.rs b/embassy-net/src/tcp.rs index 9dfbba32b..906102bbf 100644 --- a/embassy-net/src/tcp.rs +++ b/embassy-net/src/tcp.rs @@ -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 {