Struct django_query::filtering::OperatorSet
source · [−]pub struct OperatorSet<R> { /* private fields */ }
Expand description
A collection of filters for a particular type.
A 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
sourceimpl<R: Filterable> OperatorSet<R>
impl<R: Filterable> OperatorSet<R>
sourcepub fn new() -> Self
pub fn new() -> Self
Create a new OperatorSet
, by obtaining the Meta
record
from the target type, and visiting its fields and their
operators.
sourcepub fn create_filter(
&self,
field: &str,
operator: Option<&str>,
rhs: &str
) -> Result<Box<dyn Filter<R>>, FilterError>
pub fn create_filter(
&self,
field: &str,
operator: Option<&str>,
rhs: &str
) -> Result<Box<dyn Filter<R>>, 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>>, FilterError>
pub fn create_filter_from_query_pair(
&self,
lhs: &str,
rhs: &str
) -> Result<Box<dyn Filter<R>>, 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 to 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>>, FilterError>
pub fn create_filter_from_query(
&self,
expr: &str
) -> Result<Box<dyn Filter<R>>, 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 to test to objects of the target type, returning
either true
(include) or false
(exclude).
Trait Implementations
sourceimpl<R: Filterable> Default for OperatorSet<R>
impl<R: Filterable> Default for OperatorSet<R>
sourceimpl<R> MetaVisitor<R> for OperatorSet<R>
impl<R> MetaVisitor<R> for OperatorSet<R>
sourcefn visit_member<F, O, T>(&mut self, name: &str, field: &F, defop: O) where
F: Member<R, Value = T> + Clone + 'static,
O: OperatorClass<<T as Operable>::Base> + 'static,
<O as OperatorClass<<T as Operable>::Base>>::Instance: 'static,
T: Operable,
fn visit_member<F, O, T>(&mut self, name: &str, field: &F, defop: O) where
F: Member<R, Value = T> + Clone + 'static,
O: OperatorClass<<T as Operable>::Base> + 'static,
<O as OperatorClass<<T as Operable>::Base>>::Instance: 'static,
T: Operable,
Auto Trait Implementations
impl<R> !RefUnwindSafe for OperatorSet<R>
impl<R> !Send for OperatorSet<R>
impl<R> !Sync for OperatorSet<R>
impl<R> Unpin for OperatorSet<R>
impl<R> !UnwindSafe for OperatorSet<R>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more