Function datagram_builder::serialize::serialize_datagrams
source · pub fn serialize_datagrams<T, I>(
items: I,
builder: &mut impl DatagramBuilder,
) -> Result<Vec<Vec<u8>>>Expand description
Serializes a list of items into datagrams.
Each datagram is constructed using the provided DatagramBuilder. Items are serialized
and packed into datagrams without exceeding the max_packet_size.
§Arguments
items- A slice of items to serialize.max_packet_size- The maximum size of each packet.builder- A mutable reference to an implementation ofDatagramBuilder.
§Returns
io::Result<Vec<Vec<u8>>>- A vector of serialized datagrams.
§Errors
Returns an io::Error if any item is too large to fit in a packet or if serialization fails.