pub fn make_fragmented_messages<T: LevinBody>(
protocol: &Protocol,
fragment_size: usize,
message: T,
) -> Result<Vec<Bucket<T::Command>>, BucketError>
Expand description
Fragments the provided message into buckets which, when serialised, will all be the size of fragment_size
.
This function will produce many buckets that have to be sent in order. When the peer receives these buckets they will combine them to produce the original message.
The last bucket may be padded with zeros to make it the correct size, the format used to encode the body must allow for extra data at the end of the message this to work.
fragment_size
must be more than 2 * HEADER_SIZE
otherwise this will panic.