Skip to main content

reassemble_binary

Function reassemble_binary 

Source
pub fn reassemble_binary(frames: &[Vec<u8>]) -> Result<(u8, Vec<u8>)>
Expand description

Reassembles a complete sequence of frames into the original message.

Accepts a single unfragmented frame, returning its id and body unchanged, as well as the fragment sequence split_binary produces. A session that reads frame by frame keeps a Reassembler instead; this is the batch form for a sequence that is already in hand.

The framing carries no byte count and no sequence number, so a fragment lost from the middle of a message cannot be detected here. What is detectable is rejected: a continuation before the first fragment, a first flag on a later fragment, data after the last fragment, a missing last fragment, reserved flag bits, an original id of BINARY_MESSAGE_ID_FRAGMENT, and a message larger than MAX_REASSEMBLED_LEN.

ยงErrors

Returns an error when the frames are empty, cannot form exactly one well-formed message, or exceed MAX_REASSEMBLED_LEN.