pub struct Filter { /* private fields */ }Expand description
Raw parsed filter from query string.
Implements FromRequestParts so it can be used directly as an axum
handler argument. Must be validated against a FilterSchema via
validate before use in SQL generation.
§Supported query-string syntax
| Pattern | Meaning |
|---|---|
field=value | Equality (=), or IN if multiple values |
field.ne=value | Not equal (!=) |
field.gt=value | Greater than (>) |
field.gte=value | Greater than or equal (>=) |
field.lt=value | Less than (<) |
field.lte=value | Less than or equal (<=) |
field.like=value | SQL LIKE |
field.null=true | IS NULL / IS NOT NULL |
sort=field | Sort ascending; sort=-field for descending; repeat for multi-column |
Implementations§
Source§impl Filter
impl Filter
Sourcepub fn from_query_params(params: &HashMap<String, Vec<String>>) -> Self
pub fn from_query_params(params: &HashMap<String, Vec<String>>) -> Self
Parse filter conditions from a pre-parsed query string map.
Pagination parameters (page, per_page, after) are silently
skipped. Unknown operators are ignored.
Sourcepub fn validate(self, schema: &FilterSchema) -> Result<ValidatedFilter>
pub fn validate(self, schema: &FilterSchema) -> Result<ValidatedFilter>
Validate against a schema, producing a ValidatedFilter.
Unknown columns are silently ignored. Sort fields not listed in the schema are dropped.
§Errors
Returns a 400 error if a filter value cannot be converted to the
declared FieldType (e.g., "abc" for an Int field).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Filter
impl RefUnwindSafe for Filter
impl Send for Filter
impl Sync for Filter
impl Unpin for Filter
impl UnsafeUnpin for Filter
impl UnwindSafe for Filter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<S, T> FromRequest<S, ViaParts> for T
impl<S, T> FromRequest<S, ViaParts> for T
Source§type Rejection = <T as FromRequestParts<S>>::Rejection
type Rejection = <T as FromRequestParts<S>>::Rejection
If the extractor fails it’ll use this “rejection” type. A rejection is
a kind of error that can be converted into a response.
Source§fn from_request(
req: Request<Body>,
state: &S,
) -> impl Future<Output = Result<T, <T as FromRequest<S, ViaParts>>::Rejection>>
fn from_request( req: Request<Body>, state: &S, ) -> impl Future<Output = Result<T, <T as FromRequest<S, ViaParts>>::Rejection>>
Perform the extraction.