Skip to main content

Module peek

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§

ClientFirstEgress
A PeekEgressPredicate for a client-first protocol: any egress byte is a mismatch.
NoEgressPeek
A PeekEgressPredicate that never reads the egress.
PeekCutoffError
A PeekCutoff for which the PeekPolicy selected PeekAction::Fail.
PeekEgress
The egress side a PeekWaiter reads while a peek waits for ingress input.
PeekEgressPrefix
A PeekEgressPredicate for a server that opens with a fixed prefix, mirroring PeekRouter::from_prefix for the ingress.
PeekOptions
Options of the functional peekers that read both sides of a bridge.
PeekOutput
Result of a peek_input_until_verdict call.
PeekPolicy
Decides what a PeekCutoff does, given the PeekProgress of the ingress peek.
PeekRouter
A generic Service router driven by a fail-fast PeekVerdict predicate.
PeekWaiter
Reads peek input, bounded by a scope and classifying the egress as directed by a PeekPolicy.

Enums§

PeekAction
Action a PeekPolicy selects for a PeekCutoff.
PeekCutoff
Event that cuts a peek short before it reached a verdict.
PeekProgress
How far a peek got when a PeekCutoff happened.
PeekRead
Outcome of a single PeekWaiter::read.
PeekStopReason
Reason a protocol peek operation stopped.
PeekVerdict
Verdict returned by a fail-fast peek predicate, used with peek_input_until_verdict and peek_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§

PeekEgressPredicate
Judges the bytes the egress (server) side sent while a peek waits for the client.
PeekPolicyProvider
Selects the PeekPolicy a peeker applies to one input.

Functions§

peek_input_until_verdict
Read into the fixed buffer until predicate decides, peeking stops, or the waiter cuts 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 like peek_input_until_verdict.
peek_input_until_verdict_growing_with_output
Same as peek_input_until_verdict_growing, but returns the complete PeekOutput so callers can distinguish a cutoff from a definitive rejection and other inconclusive stop conditions.
replay_peeked
Map a peeked input so its ingress first replays ingress_prefix and its egress, if any, first replays egress_prefix, see PeekWaiter::finish.

Type Aliases§

PeekMapped
The input of a PeekIoProvider once peeked: the ingress mapped to PeekedIo and the egress, if any, replaying the egress bytes the peek consumed.
PeekPrefixedIo
PrefixedIo alias used by PeekRouter.