Skip to main content

PeekEgressPredicate

Trait PeekEgressPredicate 

pub trait PeekEgressPredicate: Send + Sync {
    // Required methods
    fn egress(&self, bytes: &[u8]) -> PeekVerdict<()>;
    fn peeks_egress(&self) -> bool;
}
Available on crate feature std only.
Expand description

Judges the bytes the egress (server) side sent while a peek waits for the client.

VerdictMeaningEffect
Matchdefinitively the server side of this protocolkeep waiting for the client; stop reading egress
NeedMorea valid prefix of it so farkeep waiting; read more egress
Rejectcannot be this protocol, whatever followsPeekCutoff::EgressMismatch

Implementations must be prefix-closed (once Reject or Match, always the same for any extension) and only Reject bytes a standard client of the protocol refuses as the start of the server’s side; when unsure, NeedMore. Reaching the egress size limit while NeedMore keeps waiting.

A Match keeps the peek waiting for the client, so a server-first protocol whose opening matches waits until the client speaks or the scope the input runs in ends: bound that scope where this matters. Once settled the egress is not read again, so a server closing after a matching opening is seen by the service that follows the verdict.

Closures Fn(&[u8]) -> PeekVerdict<()> implement it and peek the egress.

Required Methods§

fn egress(&self, bytes: &[u8]) -> PeekVerdict<()>

Judge the egress bytes received so far, never empty.

fn peeks_egress(&self) -> bool

Whether the egress is read at all.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§