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

Function read_pg_message

nodedb/tests/pgwire_tls_e2e.rs:160–171  ·  view source on GitHub ↗

Read a single pgwire message from the stream. Returns `(type_byte, payload)` where payload excludes the 4-byte length field.

(r: &mut R)

Source from the content-addressed store, hash-verified

158/// Read a single pgwire message from the stream.
159/// Returns `(type_byte, payload)` where payload excludes the 4-byte length field.
160async fn read_pg_message<R: AsyncReadExt + Unpin>(r: &mut R) -> (u8, Vec<u8>) {
161 let mut header = [0u8; 5];
162 r.read_exact(&mut header).await.expect("read msg header");
163 let msg_type = header[0];
164 let length = u32::from_be_bytes(header[1..5].try_into().unwrap()) as usize;
165 let payload_len = length.saturating_sub(4);
166 let mut payload = vec![0u8; payload_len];
167 if payload_len > 0 {
168 r.read_exact(&mut payload).await.expect("read msg payload");
169 }
170 (msg_type, payload)
171}
172
173// ── Test ──────────────────────────────────────────────────────────────────
174

Callers 1

Calls 2

expectMethod · 0.45
read_exactMethod · 0.45

Tested by

no test coverage detected