MCPcopy Create free account
hub / github.com/PerroEngine/Perro / decode_next_frame

Function decode_next_frame

perro_source/api_modules/perro_networking/src/tcp.rs:284–306  ·  view source on GitHub ↗
(
    buffer: &mut Vec<u8>,
    max_frame_bytes: usize,
)

Source from the content-addressed store, hash-verified

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 ));

Callers 1

poll_frameMethod · 0.85

Calls 2

to_vecMethod · 0.80
lenMethod · 0.45

Tested by

no test coverage detected