Skip to main content

write_frame

Function write_frame 

Source
pub async fn write_frame<W: AsyncWrite + Unpin>(
    w: &mut W,
    payload: &[u8],
) -> Result<(), FrameError>
Expand description

Write one length-prefixed frame to an async writer.

The writer checks only that the length fits the u32 prefix. The chunk encoders refuse a frame above crate::client::MAX_CHUNK_FRAME. Every other message is small by shape, and the worst-case encode tests beside each ceiling pin that it fits the read that receives it.

ยงErrors

FrameError::TooLarge when the payload length does not fit a u32, and FrameError::Io when the stream fails.