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

Function write_frame

nodedb/src/control/server/native/codec.rs:70–82  ·  view source on GitHub ↗

Write a single frame to the stream.

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

Source from the content-addressed store, hash-verified

68
69/// Write a single frame to the stream.
70pub async fn write_frame<W: AsyncWrite + Unpin>(
71 stream: &mut W,
72 payload: &[u8],
73) -> crate::Result<()> {
74 let len = payload.len() as u32;
75 stream
76 .write_all(&len.to_be_bytes())
77 .await
78 .map_err(crate::Error::Io)?;
79 stream.write_all(payload).await.map_err(crate::Error::Io)?;
80 stream.flush().await.map_err(crate::Error::Io)?;
81 Ok(())
82}
83
84/// Decode a request payload according to the detected format.
85pub fn decode_request(payload: &[u8], format: FrameFormat) -> crate::Result<NativeRequest> {

Callers 2

runMethod · 0.70

Calls 2

lenMethod · 0.45
flushMethod · 0.45

Tested by

no test coverage detected