Skip to main content

StatusCodePredicate

Trait StatusCodePredicate 

Source
pub trait StatusCodePredicate: Sized {
    // Required methods
    fn status_code(self, status_code: StatusCode) -> StatusCode<Self>;
    fn status_code_in(self, codes: Vec<StatusCode>) -> StatusCode<Self>;
    fn status_code_range(
        self,
        start: StatusCode,
        end: StatusCode,
    ) -> StatusCode<Self>;
    fn status_code_class(self, class: StatusClass) -> StatusCode<Self>;
}
Expand description

Extension trait for adding status code matching to a predicate chain.

§For Callers

Chain these methods to match responses by their HTTP status code. Use status_code for exact matches, status_code_class for broad categories (like “all 2xx”), or status_code_in/status_code_range for flexible matching.

§For Implementors

This trait is automatically implemented for all Predicate types. You don’t need to implement it manually.

Required Methods§

Source

fn status_code(self, status_code: StatusCode) -> StatusCode<Self>

Matches an exact status code.

Source

fn status_code_in(self, codes: Vec<StatusCode>) -> StatusCode<Self>

Matches any of the specified status codes.

Source

fn status_code_range( self, start: StatusCode, end: StatusCode, ) -> StatusCode<Self>

Matches status codes within a range (inclusive).

Source

fn status_code_class(self, class: StatusClass) -> StatusCode<Self>

Matches all status codes in a class (e.g., all 2xx).

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl<P> StatusCodePredicate for P
where P: Predicate,