Skip to main content

read_fixed_vec

Function read_fixed_vec 

Source
pub fn read_fixed_vec<T: Read + FixedSize>(
    buf: &mut impl Buf,
    len: usize,
    cfg: &T::Cfg,
) -> Result<Vec<T>, Error>
Expand description

Reads len values of a FixedSize type from the buffer into a vector.

Checks that the buffer contains all len * SIZE bytes before allocating or decoding, so a maliciously large len fails fast with Error::EndOfBuffer. Intended as a Read::read_vec override for FixedSize element types.