pub struct SearchEmailsQuery {
pub filter: Option<SearchEmailsFilterQuery>,
pub sort: Option<SearchEmailsSortQuery>,
}
Expand description
The search emails query structure.
The query is composed of a recursive SearchEmailsFilterQuery
and a list of [SearchEmailsSorter
]s.
Fields§
§filter: Option<SearchEmailsFilterQuery>
The recursive emails search filter query.
sort: Option<SearchEmailsSortQuery>
The emails search sort query.
Implementations§
Source§impl SearchEmailsQuery
impl SearchEmailsQuery
pub fn to_imap_search_criteria(&self) -> Vec1<SearchKey<'static>>
pub fn to_imap_sort_criteria(&self) -> Vec1<SortCriterion>
Source§impl SearchEmailsQuery
impl SearchEmailsQuery
pub fn matches_maildir_search_query( &self, envelope: &Envelope, msg_path: &Path, ) -> bool
Trait Implementations§
Source§impl Clone for SearchEmailsQuery
impl Clone for SearchEmailsQuery
Source§fn clone(&self) -> SearchEmailsQuery
fn clone(&self) -> SearchEmailsQuery
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for SearchEmailsQuery
impl Debug for SearchEmailsQuery
Source§impl FromStr for SearchEmailsQuery
Parse the given string slice into a SearchEmailsQuery
.
impl FromStr for SearchEmailsQuery
Parse the given string slice into a SearchEmailsQuery
.
Because of the recursive nature of SearchEmailsFilterQuery
, it
is not possible to directly parse a full query from a string using
chumsky
. Instead the string is splitted in two, and filters
and sorters are parsed separately.
A search emails query string can contain a filter query, a sorter
query or both. In this last case, the filter query needs to be
defined first, then the sorter query. They should be separated by
the keyword "order by"
.
See filter::parser::query
for more details on the filter query
string API, and sort::parser::query
for more details on the
sort query API.
§Examples
use email::search_query::SearchEmailsQuery;
use std::str::FromStr;
pub fn main() {
// filter only
"subject foo and body bar".parse::<SearchEmailsQuery>().unwrap();
// sort only
"order by date desc".parse::<SearchEmailsQuery>().unwrap();
// filter then sort
"subject foo and body bar order by subject".parse::<SearchEmailsQuery>().unwrap();
}
§ABNF
query = filter-query / "order by" SP sort-query / filter-query SP "order by" SP sort-query
filter-query = filter *(SP filter)
filter = "(" filter ")"
; nested filter
filter =/ and / or / not
; filter operators
filter =/ date / before-date / after-date / from / to / subject / body / flag
; filter conditions
and = filter SP "and" SP filter
or = filter SP "or" SP filter
not = "not" SP filter
date = "date" SP date-pattern
before-date = "before" SP date-pattern
after-date = "before" SP date-pattern
from = "from" SP text-pattern
to = "to" SP text-pattern
subject = "subject" SP text-pattern
body = "body" SP text-pattern
flag = "flag" SP text-pattern
date-pattern = 4DIGIT "-" 2DIGIT "-" 2DIGIT
; date matching "YYYY-MM-dd" format
date-pattern =/ 4DIGIT "/" 2DIGIT "/" 2DIGIT
; date matching "YYYY/MM/dd" format
date-pattern =/ 2DIGIT "-" 2DIGIT "-" 4DIGIT
; date matching "dd-MM-YYYY" format
date-pattern =/ 2DIGIT "/" 2DIGIT "/" 4DIGIT
; date matching "dd/MM/YYYY" format
text-pattern = DQUOTE *VCHAR DQUOTE
sort-query = sorter *(SP sorter)
sorter = sorter-kind [SP sorter-order]
sorter-kind = "date" / "from" / "to" / "subject"
sorter-order = "asc" / "desc"
Source§impl Ord for SearchEmailsQuery
impl Ord for SearchEmailsQuery
Source§fn cmp(&self, other: &SearchEmailsQuery) -> Ordering
fn cmp(&self, other: &SearchEmailsQuery) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for SearchEmailsQuery
impl PartialEq for SearchEmailsQuery
Source§impl PartialOrd for SearchEmailsQuery
impl PartialOrd for SearchEmailsQuery
impl Eq for SearchEmailsQuery
impl StructuralPartialEq for SearchEmailsQuery
Auto Trait Implementations§
impl Freeze for SearchEmailsQuery
impl RefUnwindSafe for SearchEmailsQuery
impl Send for SearchEmailsQuery
impl Sync for SearchEmailsQuery
impl Unpin for SearchEmailsQuery
impl UnwindSafe for SearchEmailsQuery
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more