Function peek_input_until_with_options
pub 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,
) -> impl Future<Output = PeekOutput<O>>std only.Expand description
Same as peek_input_until but with explicit control over the starting offset
and the read-attempt budget.
The predicate is evaluated against the prefilled prefix before reading.
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.
This is an Option-predicate wrapper over
peek_input_until_verdict_with_options: Some maps to
PeekVerdict::Match and None to PeekVerdict::NeedMore (it never
rejects). Use the verdict variant directly when you want fail-fast rejection.