MCPcopy Create free account
hub / github.com/aeroxy/chrome-devtools-cli / write_msg

Function write_msg

src/protocol.rs:69–75  ·  view source on GitHub ↗

Write a length-prefixed message to a stream.

(w: &mut W, data: &[u8])

Source from the content-addressed store, hash-verified

67
68/// Write a length-prefixed message to a stream.
69pub async fn write_msg<W: AsyncWriteExt + Unpin>(w: &mut W, data: &[u8]) -> anyhow::Result<()> {
70 let len = (data.len() as u32).to_be_bytes();
71 w.write_all(&len).await?;
72 w.write_all(data).await?;
73 w.flush().await?;
74 Ok(())
75}
76
77/// Read a length-prefixed message from a stream.
78pub async fn read_msg<R: AsyncReadExt + Unpin>(r: &mut R) -> anyhow::Result<Vec<u8>> {

Callers 2

handle_connectionFunction · 0.85
send_to_daemonFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected