MCPcopy Create free account
hub / github.com/ermak-dev/cloudpub / read

Method read

common/src/protocol.rs:424–445  ·  view source on GitHub ↗
(reader: &mut T, hdr_len: u8)

Source from the content-addressed store, hash-verified

422 }
423
424 pub async fn read<T: AsyncRead + Unpin>(reader: &mut T, hdr_len: u8) -> Result<UdpTraffic> {
425 let mut buf = vec![0; hdr_len as usize];
426 reader
427 .read_exact(&mut buf)
428 .await
429 .with_context(|| "Failed to read udp header")?;
430
431 let hdr: UdpHeader = bincode::serde::decode_from_slice(&buf, bincode::config::legacy())
432 .with_context(|| "Failed to deserialize UdpHeader")?
433 .0;
434
435 trace!("hdr {:?}", hdr);
436
437 let mut data = BytesMut::new();
438 data.resize(hdr.len as usize, 0);
439 reader.read_exact(&mut data).await?;
440
441 Ok(UdpTraffic {
442 from: hdr.from,
443 data: data.freeze(),
444 })
445 }
446}

Callers 15

send_single_ping_tcpFunction · 0.80
pong_tcpFunction · 0.80
downloadFunction · 0.80
main_loopFunction · 0.80
fromMethod · 0.80
run_control_channelMethod · 0.80
spawnMethod · 0.80
portMethod · 0.80
check_enviromentFunction · 0.80
publishMethod · 0.80
setupMethod · 0.80
publishMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected