Function peek_input_until_verdict_growing
pub async fn peek_input_until_verdict_growing<R, O, P>(
reader: &mut R,
buffer: &mut Vec<u8>,
max_len: usize,
read_chunk: NonZero<usize>,
timeout: Option<Duration>,
predicate: P,
) -> Option<O>std only.Expand description
Fail-fast peek that grows its buffer on demand up to max_len, instead
of reading into a fixed caller-provided slice like
peek_input_until_verdict_with_options.
Use this for a variable-length prefix (e.g. a TLS ClientHello) so the buffer
tracks the bytes actually received rather than being pre-sized to a length
the peer declared: memory stays proportional to real input, while max_len
still bounds a very large — or lying — peer. Once the buffer reaches
max_len without a verdict, peeking stops with no match.
buffer is caller-owned and may already hold an earlier peek (e.g. a record
header); a non-empty existing prefix is classified first and preserved for
replay. The predicate is never called with an empty slice. The buffer grows
in read_chunk-sized steps. Returns the matched value, or None on reject /
EOF / timeout / reaching max_len without a match; either way buffer is
left holding exactly the peeked bytes.