Trait Operable

Source
pub trait Operable {
    type Base;

    // Required method
    fn apply<O: Operator<Self::Base>>(&self, op: &O) -> bool;
}
Available on crate feature filter only.
Expand description

A type that Django filters can work on.

Django filters are defined in terms of operators on simple values, like strings and numbers. There is additional complexity, however, because these simple specifications can also be applied to collections and nullable values.

All types that occur naturally in Django queries can be made Operable, but so can, for example, Vec<T> and Option<T>, when the T in question is itself Operable. It’s up to an Operable implementation to decide how to take an operator on its base type and apply it to its contents, for example by iterating over whatever contents it has.

The implementations for Vec<T> and Option<T> match the default behaviour in Django.

Required Associated Types§

Source

type Base

The underlying type that operators should be applied to.

Required Methods§

Source

fn apply<O: Operator<Self::Base>>(&self, op: &O) -> bool

Apply op across our contents.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<T> Operable for Option<T>
where T: Operable,

Source§

type Base = <T as Operable>::Base

Source§

fn apply<O: Operator<Self::Base>>(&self, op: &O) -> bool

Source§

impl<T> Operable for Vec<T>
where T: Operable,

Source§

type Base = <T as Operable>::Base

Source§

fn apply<O: Operator<Self::Base>>(&self, op: &O) -> bool

Implementors§

Source§

impl<T> Operable for T
where T: Scalar,

Source§

type Base = T