Function peek_input_until_with_options
pub async fn peek_input_until_with_options<R, O, P>(
reader: &mut R,
buffer: &mut [u8],
offset: usize,
timeout: Option<Duration>,
max_attempts: Option<NonZero<usize>>,
predicate: P,
) -> PeekOutput<O>Expand description
Same as peek_input_until but with explicit control over the starting offset
and the read-attempt budget.
max_attempts:
Some(n)— stop afternread attempts even if the predicate did not match.None— no attempt cap; rely on the reader’s EOF and the optionaltimeout.
The default budget used by peek_input_until and peek_input_until_with_offset
is derived from the buffer length (max(buffer.len() / 4, 1) + 1), which is a
reasonable fallback for sizable buffers but can be too tight for small protocol-
sniffing buffers under TCP fragmentation. Prefer this function with an explicit
budget when reading from untrusted/proxied peers.