(
buffer: &mut Vec<u8>,
max_frame_bytes: usize,
)
| 282 | self.tx_cursor += n; |
| 283 | if self.tx_cursor == bytes.len() { |
| 284 | self.tx_queue.pop_front(); |
| 285 | self.tx_cursor = 0; |
| 286 | } |
| 287 | } |
| 288 | Err(err) if err.kind() == io::ErrorKind::WouldBlock => return Ok(false), |
| 289 | Err(err) => return Err(NetError::from_io(NetErrorKind::Send, err)), |
| 290 | } |
| 291 | } |
| 292 | Ok(true) |
| 293 | } |
| 294 | |
| 295 | /// Bytes accepted by buffered writes but not yet sent to the socket. |
| 296 | pub fn pending_write_bytes(&self) -> usize { |
| 297 | self.tx_queue |
| 298 | .iter() |
| 299 | .map(Vec::len) |
| 300 | .sum::<usize>() |
| 301 | .saturating_sub(self.tx_cursor) |
| 302 | } |
| 303 | |
| 304 | fn enqueue_write(&mut self, bytes: Vec<u8>) -> NetResult<()> { |
| 305 | if self.pending_write_bytes().saturating_add(bytes.len()) > MAX_TCP_PENDING_WRITE_BYTES { |
| 306 | return Err(NetError::new( |
| 307 | NetErrorKind::Send, |
| 308 | "tcp pending write queue exceeds max", |
| 309 | )); |
no test coverage detected