pub trait AsQuery<S> {
// Required method
fn into_query(self) -> Option<Query<S>>;
// Provided methods
fn and(self, other: impl AsQuery<S>) -> Query<S>
where Self: Sized { ... }
fn or(self, other: impl AsQuery<S>) -> Query<S>
where Self: Sized { ... }
fn not(self) -> Query<S>
where Self: Sized { ... }
fn to_value(&self) -> Value
where Self: Sized + Clone { ... }
}Expand description
Anything that can become a query clause in scope S. A clause may be absent
(into_query returns None) — that’s what makes an
Option<Query<S>> a first-class optional filter.
The leaf-query builders (TermQuery,
WildcardQuery, MatchQuery, …)
implement this, so they drop straight into Search clauses
and into and/or/not with no explicit .build(). The combinators here
are provided methods; on a Query the inherent ones win, so a builder
gains and/or/not/to_value for free while Query’s behavior is
unchanged.
Required Methods§
Sourcefn into_query(self) -> Option<Query<S>>
fn into_query(self) -> Option<Query<S>>
The clause this produces, or None to contribute nothing.
Provided Methods§
Sourcefn and(self, other: impl AsQuery<S>) -> Query<S>where
Self: Sized,
fn and(self, other: impl AsQuery<S>) -> Query<S>where
Self: Sized,
self AND other. An absent side is the identity.
Sourcefn or(self, other: impl AsQuery<S>) -> Query<S>where
Self: Sized,
fn or(self, other: impl AsQuery<S>) -> Query<S>where
Self: Sized,
self OR other. An absent side is the identity.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".