Function datagram_builder::deserialize::deserialize_datagrams

source ·
pub fn deserialize_datagrams<T, I>(
    datagrams: I,
    parser: &mut impl DatagramParser,
) -> Result<Vec<T>>
where T: Deserialize, I: IntoIterator<Item = Vec<u8>>,
Expand description

Deserializes a collection of datagrams into a vector of items.

Each datagram is parsed to extract its payload, and the payload is then deserialized into items of type T. All successfully deserialized items are aggregated into a single vector.

§Arguments

  • datagrams - An iterable collection of byte slices, each representing a serialized datagram.
  • parser - A mutable reference to an implementation of DatagramParser.

§Returns

  • io::Result<Vec<T>> - A vector of deserialized items.

§Errors

Returns an io::Error if parsing any datagram or deserializing any item fails.