Move Query to melib
parent
c37d8bd331
commit
3d7b9ff7cb
|
@ -123,6 +123,7 @@ pub mod thread;
|
||||||
pub use crate::email::*;
|
pub use crate::email::*;
|
||||||
pub use crate::thread::*;
|
pub use crate::thread::*;
|
||||||
pub mod parsec;
|
pub mod parsec;
|
||||||
|
pub mod search;
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate serde_derive;
|
extern crate serde_derive;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* meli
|
* meli - melib
|
||||||
*
|
*
|
||||||
* Copyright 2017-2018 Manos Pitsidianakis
|
* Copyright 2019-2020 Manos Pitsidianakis
|
||||||
*
|
*
|
||||||
* This file is part of meli.
|
* This file is part of meli.
|
||||||
*
|
*
|
||||||
|
@ -19,11 +19,9 @@
|
||||||
* along with meli. If not, see <http://www.gnu.org/licenses/>.
|
* along with meli. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*! Search queries.
|
use crate::parsec::*;
|
||||||
*/
|
use crate::UnixTimestamp;
|
||||||
use melib::parsec::*;
|
use crate::{
|
||||||
use melib::UnixTimestamp;
|
|
||||||
use melib::{
|
|
||||||
backends::{MailBackend, MailboxHash},
|
backends::{MailBackend, MailboxHash},
|
||||||
email::EnvelopeHash,
|
email::EnvelopeHash,
|
||||||
thread::{SortField, SortOrder},
|
thread::{SortField, SortOrder},
|
||||||
|
@ -65,7 +63,7 @@ pub trait QueryTrait {
|
||||||
fn is_match(&self, query: &Query) -> bool;
|
fn is_match(&self, query: &Query) -> bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl QueryTrait for melib::Envelope {
|
impl QueryTrait for crate::Envelope {
|
||||||
fn is_match(&self, query: &Query) -> bool {
|
fn is_match(&self, query: &Query) -> bool {
|
||||||
use Query::*;
|
use Query::*;
|
||||||
match query {
|
match query {
|
||||||
|
@ -233,7 +231,7 @@ pub mod query_parser {
|
||||||
/// ```
|
/// ```
|
||||||
/// use ui::cache::query;
|
/// use ui::cache::query;
|
||||||
/// use ui::cache::Query;
|
/// use ui::cache::Query;
|
||||||
/// use melib::parsec::Parser;
|
/// use crate::parsec::Parser;
|
||||||
///
|
///
|
||||||
/// let input = "test";
|
/// let input = "test";
|
||||||
/// let query = query().parse(input);
|
/// let query = query().parse(input);
|
||||||
|
@ -474,7 +472,7 @@ pub fn imap_search(
|
||||||
let backend_lck = backend.read().unwrap();
|
let backend_lck = backend.read().unwrap();
|
||||||
|
|
||||||
let b = (*backend_lck).as_any();
|
let b = (*backend_lck).as_any();
|
||||||
if let Some(imap_backend) = b.downcast_ref::<melib::backends::ImapType>() {
|
if let Some(imap_backend) = b.downcast_ref::<crate::backends::ImapType>() {
|
||||||
imap_backend.search(query_to_imap(&query), mailbox_hash)
|
imap_backend.search(query_to_imap(&query), mailbox_hash)
|
||||||
} else {
|
} else {
|
||||||
panic!("Could not downcast ImapType backend. BUG");
|
panic!("Could not downcast ImapType backend. BUG");
|
|
@ -84,7 +84,6 @@ use crate::workers::*;
|
||||||
#[cfg(feature = "sqlite3")]
|
#[cfg(feature = "sqlite3")]
|
||||||
pub mod sqlite3;
|
pub mod sqlite3;
|
||||||
|
|
||||||
pub mod cache;
|
|
||||||
pub mod mailcap;
|
pub mod mailcap;
|
||||||
pub mod plugins;
|
pub mod plugins;
|
||||||
|
|
||||||
|
|
|
@ -754,7 +754,7 @@ impl CompactListing {
|
||||||
let root_envelope: EnvelopeRef = context.accounts[self.cursor_pos.0]
|
let root_envelope: EnvelopeRef = context.accounts[self.cursor_pos.0]
|
||||||
.collection
|
.collection
|
||||||
.get_env(root_env_hash);
|
.get_env(root_env_hash);
|
||||||
use crate::cache::QueryTrait;
|
use melib::search::QueryTrait;
|
||||||
if let Some(filter_query) = mailbox_settings!(
|
if let Some(filter_query) = mailbox_settings!(
|
||||||
context[self.cursor_pos.0][&self.cursor_pos.1]
|
context[self.cursor_pos.0][&self.cursor_pos.1]
|
||||||
.listing
|
.listing
|
||||||
|
|
|
@ -703,7 +703,7 @@ impl ConversationsListing {
|
||||||
let root_envelope: &EnvelopeRef = &context.accounts[self.cursor_pos.0]
|
let root_envelope: &EnvelopeRef = &context.accounts[self.cursor_pos.0]
|
||||||
.collection
|
.collection
|
||||||
.get_env(root_env_hash);
|
.get_env(root_env_hash);
|
||||||
use crate::cache::QueryTrait;
|
use melib::search::QueryTrait;
|
||||||
if let Some(filter_query) = mailbox_settings!(
|
if let Some(filter_query) = mailbox_settings!(
|
||||||
context[self.cursor_pos.0][&self.cursor_pos.1]
|
context[self.cursor_pos.0][&self.cursor_pos.1]
|
||||||
.listing
|
.listing
|
||||||
|
|
|
@ -711,7 +711,7 @@ impl PlainListing {
|
||||||
panic!();
|
panic!();
|
||||||
}
|
}
|
||||||
let envelope: EnvelopeRef = context.accounts[self.cursor_pos.0].collection.get_env(i);
|
let envelope: EnvelopeRef = context.accounts[self.cursor_pos.0].collection.get_env(i);
|
||||||
use crate::cache::QueryTrait;
|
use melib::search::QueryTrait;
|
||||||
if let Some(filter_query) = mailbox_settings!(
|
if let Some(filter_query) = mailbox_settings!(
|
||||||
context[self.cursor_pos.0][&self.cursor_pos.1]
|
context[self.cursor_pos.0][&self.cursor_pos.1]
|
||||||
.listing
|
.listing
|
||||||
|
|
|
@ -1133,7 +1133,7 @@ impl Account {
|
||||||
mailbox_hash: MailboxHash,
|
mailbox_hash: MailboxHash,
|
||||||
) -> Result<SmallVec<[EnvelopeHash; 512]>> {
|
) -> Result<SmallVec<[EnvelopeHash; 512]>> {
|
||||||
if self.settings.account().format() == "imap" {
|
if self.settings.account().format() == "imap" {
|
||||||
return crate::cache::imap_search(search_term, sort, mailbox_hash, &self.backend);
|
return melib::search::imap_search(search_term, sort, mailbox_hash, &self.backend);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "notmuch")]
|
#[cfg(feature = "notmuch")]
|
||||||
|
|
|
@ -20,8 +20,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use super::{default_vals::*, IndexStyle};
|
use super::{default_vals::*, IndexStyle};
|
||||||
use crate::cache::Query;
|
|
||||||
use crate::override_def;
|
use crate::override_def;
|
||||||
|
use melib::search::Query;
|
||||||
|
|
||||||
override_def!(
|
override_def!(
|
||||||
ListingSettingsOverride,
|
ListingSettingsOverride,
|
||||||
|
|
|
@ -74,7 +74,6 @@ use crate::workers::*;
|
||||||
#[cfg(feature = "sqlite3")]
|
#[cfg(feature = "sqlite3")]
|
||||||
pub mod sqlite3;
|
pub mod sqlite3;
|
||||||
|
|
||||||
pub mod cache;
|
|
||||||
pub mod mailcap;
|
pub mod mailcap;
|
||||||
pub mod plugins;
|
pub mod plugins;
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
/*! Use an sqlite3 database for fast searching.
|
/*! Use an sqlite3 database for fast searching.
|
||||||
*/
|
*/
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use crate::cache::{escape_double_quote, query, Query::{self, *}};
|
use melib::search::{escape_double_quote, query, Query::{self, *}};
|
||||||
use crate::melib::parsec::Parser;
|
use crate::melib::parsec::Parser;
|
||||||
use melib::{
|
use melib::{
|
||||||
backends::MailBackend,
|
backends::MailBackend,
|
||||||
|
|
Loading…
Reference in New Issue