Skip to main content

checked_capacity

Function checked_capacity 

Source
pub fn checked_capacity(
    value: usize,
    cap: usize,
    remaining_bytes: usize,
    min_encoded_bytes: usize,
    what: &str,
) -> ArrayResult<usize>
Expand description

Validate a decoded collection count before it drives an allocation.

min_encoded_bytes is the smallest on-wire representation per entry. It rejects a tiny frame carrying a huge count before reserving memory, while the caller still validates each variable-sized entry as it is consumed.