MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / recv_until

Function recv_until

e2e/rust/tests/websocket_conformance.rs:119–132  ·  view source on GitHub ↗
(stream: &mut TcpStream, marker: &[u8])

Source from the content-addressed store, hash-verified

117}
118
119async fn recv_until(stream: &mut TcpStream, marker: &[u8]) -> io::Result<Vec<u8>> {
120 let mut data = Vec::new();
121 let mut buf = [0_u8; 1024];
122 loop {
123 let read = stream.read(&mut buf).await?;
124 if read == 0 {
125 return Ok(data);
126 }
127 data.extend_from_slice(&buf[..read]);
128 if data.windows(marker.len()).any(|window| window == marker) {
129 return Ok(data);
130 }
131 }
132}
133
134async fn read_websocket_text(stream: &mut TcpStream) -> io::Result<String> {
135 let mut header = [0_u8; 2];

Callers 1

Calls 2

lenMethod · 0.80
readMethod · 0.45

Tested by

no test coverage detected