pub struct OperatorSet<R> { /* private fields */ }
filter
only.Expand description
A collection of filters for a particular type.
An OperatorSet
can be created for any type which implements
Filterable
. Its constructor supplies a visitor to the type’s
Meta
type, and constructs the necessary FilterClass
objects.
It can be used directly to convert incoming query pairs from
Django-style query URLs into appropriate Filter
objects.
Implementations§
Source§impl<'a, R: Filterable<'a>> OperatorSet<R>
impl<'a, R: Filterable<'a>> OperatorSet<R>
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new OperatorSet
, using the Meta
record
from the target type
Sourcepub fn create_filter(
&self,
field: &str,
operator: Option<&str>,
rhs: &str,
) -> Result<Box<dyn Filter<R> + 'a>, FilterError>
pub fn create_filter( &self, field: &str, operator: Option<&str>, rhs: &str, ) -> Result<Box<dyn Filter<R> + 'a>, FilterError>
Create a new filter from a decomposed URL.
Note that the decomposition is ambiguous, so
create_filter_from_query_pair
is often preferable. The ambiguity arises because there may be
no operator part, and the field part may have arbitrarily many
parts. Since everything is separated with double underscores
there is no way without additional information to distinguish
an expression with an explicit operator from an expression on
a nested field with an implicit operator. Here
field
is the field specification part of the string, including any nested fields.operator
is the operator specification, if any.rhs
is the argument part, after the=
in the URL section.
Sourcepub fn create_filter_from_query_pair(
&self,
lhs: &str,
rhs: &str,
) -> Result<Box<dyn Filter<R> + 'a>, FilterError>
pub fn create_filter_from_query_pair( &self, lhs: &str, rhs: &str, ) -> Result<Box<dyn Filter<R> + 'a>, FilterError>
Create a new filter from a fragment of query URL.
The expected input is a lhs=rhs
pair from a query string,
with lhs
and rhs
given separately. The output will either
be an error, or a Filter
which can apply the specified
test to objects of the target type, returning either true
(include) or false
(exclude).
Sourcepub fn create_filter_from_query(
&self,
expr: &str,
) -> Result<Box<dyn Filter<R> + 'a>, FilterError>
pub fn create_filter_from_query( &self, expr: &str, ) -> Result<Box<dyn Filter<R> + 'a>, FilterError>
Create a new filter from a fragment of query URL.
The expected input is a lhs=rhs
pair from a query string,
with lhs
and rhs
given together in a single string. The
output will either be an error, or a Filter
which can apply
the specified test to objects of the target type, returning
either true
(include) or false
(exclude).