Module peek
Available on crate feature
std only.Expand description
Protocol peeking: inspect the first bytes of an input without consuming them.
A peeker classifies the first bytes from either side of a bridge: the
ingress (client) through its predicate and, on a BridgeIo, the egress
(server) through a PeekEgressPredicate. Peekers wait for input through
a PeekWaiter, which egress verdicts and the scope the input runs in
can cut short as directed by a PeekPolicy. No verdict depends on a
timeout: a waiting peek ends when its scope is cancelled or aborted.
Structs§
- Client
First Egress - A
PeekEgressPredicatefor a client-first protocol: any egress byte is a mismatch. - NoEgress
Peek - A
PeekEgressPredicatethat never reads the egress. - Peek
Cutoff Error - A
PeekCutofffor which thePeekPolicyselectedPeekAction::Fail. - Peek
Egress - The egress side a
PeekWaiterreads while a peek waits for ingress input. - Peek
Egress Prefix - A
PeekEgressPredicatefor a server that opens with a fixed prefix, mirroringPeekRouter::from_prefixfor the ingress. - Peek
Options - Options of the functional peekers that read both sides of a bridge.
- Peek
Output - Result of a
peek_input_until_verdictcall. - Peek
Policy - Decides what a
PeekCutoffdoes, given thePeekProgressof the ingress peek. - Peek
Router - A generic
Servicerouter driven by a fail-fastPeekVerdictpredicate. - Peek
Waiter - Reads peek input, bounded by a scope and classifying the egress
as directed by a
PeekPolicy.
Enums§
- Peek
Action - Action a
PeekPolicyselects for aPeekCutoff. - Peek
Cutoff - Event that cuts a peek short before it reached a verdict.
- Peek
Progress - How far a peek got when a
PeekCutoffhappened. - Peek
Read - Outcome of a single
PeekWaiter::read. - Peek
Stop Reason - Reason a protocol peek operation stopped.
- Peek
Verdict - Verdict returned by a fail-fast peek predicate, used with
peek_input_until_verdictandpeek_input_until_verdict_growing.
Constants§
- DEFAULT_
EGRESS_ PEEK_ MAX_ SIZE - Default maximum number of egress bytes a peek inspects.
- DEFAULT_
PEEK_ MAX_ SIZE - Default maximum number of bytes inspected by
PeekRouter. - DEFAULT_
PEEK_ READ_ CHUNK_ SIZE - Default number of bytes requested per read by
PeekRouter.
Traits§
- Peek
Egress Predicate - Judges the bytes the egress (server) side sent while a peek waits for the client.
- Peek
Policy Provider - Selects the
PeekPolicya peeker applies to one input.
Functions§
- peek_
input_ until_ verdict - Read into the fixed
bufferuntilpredicatedecides, peeking stops, or thewaitercuts the peek short. - peek_
input_ until_ verdict_ growing - Fail-fast peek that grows its buffer on demand up to
max_len, instead of reading into a fixed caller-provided slice likepeek_input_until_verdict. - peek_
input_ until_ verdict_ growing_ with_ output - Same as
peek_input_until_verdict_growing, but returns the completePeekOutputso callers can distinguish a cutoff from a definitive rejection and other inconclusive stop conditions. - replay_
peeked - Map a peeked
inputso its ingress first replaysingress_prefixand its egress, if any, first replaysegress_prefix, seePeekWaiter::finish.
Type Aliases§
- Peek
Mapped - The input of a
PeekIoProvideronce peeked: the ingress mapped toPeekedIoand the egress, if any, replaying the egress bytes the peek consumed. - Peek
Prefixed Io PrefixedIoalias used byPeekRouter.