MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / write_frame

Function write_frame

nodedb/tests/native_protocol.rs:225–230  ·  view source on GitHub ↗

Write a length-prefixed frame payload to the stream.

(stream: &mut TcpStream, payload: &[u8])

Source from the content-addressed store, hash-verified

223
224/// Write a length-prefixed frame payload to the stream.
225async fn write_frame(stream: &mut TcpStream, payload: &[u8]) {
226 let len = (payload.len() as u32).to_be_bytes();
227 stream.write_all(&len).await.expect("write len");
228 stream.write_all(payload).await.expect("write payload");
229 stream.flush().await.expect("flush");
230}
231
232/// Read a length-prefixed frame from the stream.
233/// Returns `None` on EOF.

Calls 3

lenMethod · 0.45
expectMethod · 0.45
flushMethod · 0.45

Tested by

no test coverage detected