pub enum PlainOperation {
Eq(Bytes),
Contains(Bytes),
Starts(Bytes),
Ends(Bytes),
RegExp(Regex),
}Expand description
Operations for matching raw body bytes.
Each operation checks the body content against a pattern and returns
Cacheable on match or
NonCacheable otherwise.
§Performance
Starts: Reads only the prefix bytes needed for comparisonContains: Uses streaming search, stops early on matchEq,Ends,RegExp: Collect the entire body
§Caveats
All operations consume the body stream. The body is returned as
BufferedBody::Complete or BufferedBody::Partial after checking.
Variants§
Eq(Bytes)
Use when the entire body must match exactly.
Best for known static responses or signatures.
Contains(Bytes)
Use when a marker or pattern appears anywhere in the body.
Best for success markers, error messages, or content indicators. Uses streaming search for efficiency.
Starts(Bytes)
Use when the body should begin with a specific prefix.
Best for magic numbers, file signatures, or protocol headers. Only reads the prefix bytes needed.
Ends(Bytes)
Use when the body should end with a specific suffix.
Best for file extensions embedded in content or trailing markers. Requires reading the entire body.
RegExp(Regex)
Use when matching complex patterns in body content.
Best for structured text, log formats, or flexible content matching. Requires reading the entire body.
Implementations§
Source§impl PlainOperation
impl PlainOperation
Sourcepub async fn check<B>(
&self,
body: BufferedBody<B>,
) -> PredicateResult<BufferedBody<B>>
pub async fn check<B>( &self, body: BufferedBody<B>, ) -> PredicateResult<BufferedBody<B>>
Checks if this operation matches the body.
Returns Cacheable when the body matches,
NonCacheable otherwise.
The returned body is always in a buffered state suitable for further processing or caching.