Skip to main content

split_payload

Function split_payload 

Source
pub fn split_payload(
    payload: &[u8],
    max_segment_size: usize,
) -> Result<Vec<Bytes>, Error>
Expand description

Split a payload into segments of at most max_segment_size bytes.

Returns at least one segment (possibly empty) whenever max_segment_size leaves room for one. A zero segment size is an error even for an empty payload: a segment still costs its PDU header, so a peer whose maximum APDU cannot hold that header cannot receive a segment at all. Returning a single empty segment there produced a frame larger than the peer had advertised.