diff options
| author | Scott Mabin <[email protected]> | 2023-08-14 20:58:44 +0100 |
|---|---|---|
| committer | Scott Mabin <[email protected]> | 2023-08-15 15:31:23 +0100 |
| commit | b1ef009c6b08ae54595ca558f4571d430e99cb0b (patch) | |
| tree | 16ae53eb887e8e1aba96f629fda046435d624391 /embassy-net/src/tcp.rs | |
| parent | b6b44480457d272aace977e885d5dba252fd2bed (diff) | |
Add tcp capacity impls
Diffstat (limited to 'embassy-net/src/tcp.rs')
| -rw-r--r-- | embassy-net/src/tcp.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/embassy-net/src/tcp.rs b/embassy-net/src/tcp.rs index b4ce40945..ab22ffb70 100644 --- a/embassy-net/src/tcp.rs +++ b/embassy-net/src/tcp.rs | |||
| @@ -93,6 +93,11 @@ impl<'a> TcpReader<'a> { | |||
| 93 | { | 93 | { |
| 94 | self.io.read_with(f).await | 94 | self.io.read_with(f).await |
| 95 | } | 95 | } |
| 96 | |||
| 97 | /// Return the maximum number of bytes inside the transmit buffer. | ||
| 98 | pub fn recv_capacity(&self) -> usize { | ||
| 99 | self.io.recv_capacity() | ||
| 100 | } | ||
| 96 | } | 101 | } |
| 97 | 102 | ||
| 98 | impl<'a> TcpWriter<'a> { | 103 | impl<'a> TcpWriter<'a> { |
| @@ -122,6 +127,11 @@ impl<'a> TcpWriter<'a> { | |||
| 122 | { | 127 | { |
| 123 | self.io.write_with(f).await | 128 | self.io.write_with(f).await |
| 124 | } | 129 | } |
| 130 | |||
| 131 | /// Return the maximum number of bytes inside the transmit buffer. | ||
| 132 | pub fn send_capacity(&self) -> usize { | ||
| 133 | self.io.send_capacity() | ||
| 134 | } | ||
| 125 | } | 135 | } |
| 126 | 136 | ||
| 127 | impl<'a> TcpSocket<'a> { | 137 | impl<'a> TcpSocket<'a> { |
| @@ -143,6 +153,16 @@ impl<'a> TcpSocket<'a> { | |||
| 143 | } | 153 | } |
| 144 | } | 154 | } |
| 145 | 155 | ||
| 156 | /// Return the maximum number of bytes inside the recv buffer. | ||
| 157 | pub fn recv_capacity(&self) -> usize { | ||
| 158 | self.io.recv_capacity() | ||
| 159 | } | ||
| 160 | |||
| 161 | /// Return the maximum number of bytes inside the transmit buffer. | ||
| 162 | pub fn send_capacity(&self) -> usize { | ||
| 163 | self.io.send_capacity() | ||
| 164 | } | ||
| 165 | |||
| 146 | /// Call `f` with the largest contiguous slice of octets in the transmit buffer, | 166 | /// Call `f` with the largest contiguous slice of octets in the transmit buffer, |
| 147 | /// and enqueue the amount of elements returned by `f`. | 167 | /// and enqueue the amount of elements returned by `f`. |
| 148 | /// | 168 | /// |
| @@ -478,6 +498,14 @@ impl<'d> TcpIo<'d> { | |||
| 478 | }) | 498 | }) |
| 479 | .await | 499 | .await |
| 480 | } | 500 | } |
| 501 | |||
| 502 | fn recv_capacity(&self) -> usize { | ||
| 503 | self.with(|s, _| s.recv_capacity()) | ||
| 504 | } | ||
| 505 | |||
| 506 | fn send_capacity(&self) -> usize { | ||
| 507 | self.with(|s, _| s.send_capacity()) | ||
| 508 | } | ||
| 481 | } | 509 | } |
| 482 | 510 | ||
| 483 | #[cfg(feature = "nightly")] | 511 | #[cfg(feature = "nightly")] |
