Struct email::search_query::SearchEmailsQuery
source · 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_sort_query(&self) -> String
pub fn to_imap_sort_criteria(&self) -> Vec<SortCriterion<'_>>
source§impl SearchEmailsQuery
impl SearchEmailsQuery
pub fn matches_maildir_search_query( &self, envelope: &Envelope, msg_path: &Path ) -> bool
source§impl SearchEmailsQuery
impl SearchEmailsQuery
pub fn to_notmuch_search_query(&self) -> String
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
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§fn eq(&self, other: &SearchEmailsQuery) -> bool
fn eq(&self, other: &SearchEmailsQuery) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for SearchEmailsQuery
impl PartialOrd for SearchEmailsQuery
source§fn partial_cmp(&self, other: &SearchEmailsQuery) -> Option<Ordering>
fn partial_cmp(&self, other: &SearchEmailsQuery) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moreimpl 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<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
source§fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
source§impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
§type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
source§fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
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<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
source§impl<T, Dst> ConvAsUtil<Dst> for T
impl<T, Dst> ConvAsUtil<Dst> for T
source§impl<T> ConvUtil for T
impl<T> ConvUtil for T
source§fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
source§fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>
fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>
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.