Implement search #61

Merged
quentin merged 13 commits from feat/search into main 2024-01-08 10:39:26 +00:00
2 changed files with 6 additions and 6 deletions
Showing only changes of commit 4e3cbf79d0 - Show all commits

View file

@ -261,7 +261,7 @@ impl<'a> FetchedMail<'a> {
Self::Partial(AnyPart::Msg(msg)) Self::Partial(AnyPart::Msg(msg))
} }
fn as_anypart(&self) -> Result<&AnyPart<'a>> { pub fn as_anypart(&self) -> Result<&AnyPart<'a>> {
match self { match self {
FetchedMail::Full(x) => Ok(&x), FetchedMail::Full(x) => Ok(&x),
FetchedMail::Partial(x) => Ok(&x), FetchedMail::Partial(x) => Ok(&x),
@ -269,7 +269,7 @@ impl<'a> FetchedMail<'a> {
} }
} }
fn as_msg(&self) -> Result<&Message<'a>> { pub fn as_msg(&self) -> Result<&Message<'a>> {
match self { match self {
FetchedMail::Full(AnyPart::Msg(x)) => Ok(&x), FetchedMail::Full(AnyPart::Msg(x)) => Ok(&x),
FetchedMail::Partial(AnyPart::Msg(x)) => Ok(&x), FetchedMail::Partial(AnyPart::Msg(x)) => Ok(&x),
@ -277,7 +277,7 @@ impl<'a> FetchedMail<'a> {
} }
} }
fn as_imf(&self) -> Option<&imf::Imf<'a>> { pub fn as_imf(&self) -> Option<&imf::Imf<'a>> {
match self { match self {
FetchedMail::Full(AnyPart::Msg(x)) => Some(&x.imf), FetchedMail::Full(AnyPart::Msg(x)) => Some(&x.imf),
FetchedMail::Partial(AnyPart::Msg(x)) => Some(&x.imf), FetchedMail::Partial(AnyPart::Msg(x)) => Some(&x.imf),

View file

@ -190,7 +190,7 @@ impl<'a> Criteria<'a> {
And(expr_list) => expr_list And(expr_list) => expr_list
.as_ref() .as_ref()
.iter() .iter()
.any(|cur| Criteria(cur).is_keep_on_query(mail_view)), .all(|cur| Criteria(cur).is_keep_on_query(mail_view)),
Or(left, right) => { Or(left, right) => {
Criteria(left).is_keep_on_query(mail_view) || Criteria(right).is_keep_on_query(mail_view) Criteria(left).is_keep_on_query(mail_view) || Criteria(right).is_keep_on_query(mail_view)
} }
@ -234,8 +234,8 @@ impl<'a> Criteria<'a> {
// Filter on the full content of the email // Filter on the full content of the email
Text(_) => unimplemented!(), Text(txt) => mail_view.content.as_msg().map(|msg| msg.raw_part.windows(txt.as_ref().len()).any(|win| win == txt.as_ref())).unwrap_or(false),
Body(_) => unimplemented!(), Body(txt) => mail_view.content.as_msg().map(|msg| msg.raw_body.windows(txt.as_ref().len()).any(|win| win == txt.as_ref())).unwrap_or(false),
unknown => { unknown => {
tracing::error!("Unknown filter {:?}", unknown); tracing::error!("Unknown filter {:?}", unknown);