Skip to main content

max_decoded_len

Function max_decoded_len 

Source
pub const fn max_decoded_len(input_len: usize) -> Option<usize>
Expand description

Returns a decoded-length upper bound for input_len bytes.

The bound holds for every reachable decoder state and every input, and includes the possible one-byte tail returned by Decoder::finish. In the worst case, an existing pending symbol makes the number of symbols at most input_len + 1. The resulting bound is monotone in that symbol count, so it completes ceil(input_len / 2) pairs of at most 14 bits and has a tail exactly when input_len is even. The quotient and remainder calculation avoids forming 14 * input_len.

None means that the mathematical bound does not fit in usize. A Some result can still exceed isize::MAX, so allocating APIs perform that separate platform-capacity check.