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

Function encode_frame

perro_source/api_modules/perro_networking/src/tcp.rs:271–282  ·  view source on GitHub ↗
(bytes: &[u8])

Source from the content-addressed store, hash-verified

269 /// Try to write all queued bytes without blocking.
270 ///
271 /// Returns `true` when the queue is empty.
272 pub fn flush_pending(&mut self) -> NetResult<bool> {
273 while let Some(bytes) = self.tx_queue.front() {
274 match self.stream.write(&bytes[self.tx_cursor..]) {
275 Ok(0) => {
276 return Err(NetError::new(
277 NetErrorKind::Send,
278 "tcp stream wrote zero bytes",
279 ));
280 }
281 Ok(n) => {
282 self.tx_cursor += n;
283 if self.tx_cursor == bytes.len() {
284 self.tx_queue.pop_front();
285 self.tx_cursor = 0;

Callers 2

write_frameMethod · 0.85

Calls 1

lenMethod · 0.45