summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManos Pitsidianakis <el13635@mail.ntua.gr>2022-11-14 19:14:19 +0200
committerManos Pitsidianakis <el13635@mail.ntua.gr>2022-11-14 19:14:19 +0200
commitbd22f986f0c06f6dae535733d484aa89f610ed46 (patch)
tree83439da2cb4730fc11e09b26660e6e473ce3d2f0
parentded9adde614ac3d38045fa97a0f5144b80855fe7 (diff)
downloadmeli-bd22f986f0c06f6dae535733d484aa89f610ed46.zip
melib: fix clippy lints
-rw-r--r--melib/src/addressbook.rs4
-rw-r--r--melib/src/backends.rs49
-rw-r--r--melib/src/backends/imap/managesieve.rs30
-rw-r--r--melib/src/backends/jmap.rs12
-rw-r--r--melib/src/backends/maildir/backend.rs27
-rw-r--r--melib/src/backends/mbox.rs94
-rw-r--r--melib/src/backends/nntp.rs29
-rw-r--r--melib/src/backends/notmuch.rs57
-rw-r--r--melib/src/conf.rs2
-rw-r--r--melib/src/email/list_management.rs2
-rw-r--r--melib/src/error.rs4
-rw-r--r--melib/src/gpgme/bindings.rs2
-rw-r--r--melib/src/gpgme/mod.rs6
-rw-r--r--melib/src/lib.rs2
-rw-r--r--melib/src/smtp.rs10
-rw-r--r--melib/src/text_processing/types.rs4
-rw-r--r--melib/src/thread.rs14
17 files changed, 252 insertions, 96 deletions
diff --git a/melib/src/addressbook.rs b/melib/src/addressbook.rs
index 36cbfaf8..276c0ae5 100644
--- a/melib/src/addressbook.rs
+++ b/melib/src/addressbook.rs
@@ -56,7 +56,7 @@ impl From<String> for CardId {
}
}
-#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
+#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
pub struct AddressBook {
display_name: String,
created: UnixTimestamp,
@@ -64,7 +64,7 @@ pub struct AddressBook {
pub cards: HashMap<CardId, Card>,
}
-#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
+#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
pub struct Card {
id: CardId,
title: String,
diff --git a/melib/src/backends.rs b/melib/src/backends.rs
index 088a34ee..b174abbd 100644
--- a/melib/src/backends.rs
+++ b/melib/src/backends.rs
@@ -398,49 +398,37 @@ pub trait MailBackend: ::std::fmt::Debug + Send + Sync {
fn create_mailbox(
&mut self,
- _path: String,
- ) -> ResultFuture<(MailboxHash, HashMap<MailboxHash, Mailbox>)> {
- Err(MeliError::new("Creating mailbox is currently unimplemented.").set_kind(ErrorKind::NotImplemented))
- }
+ path: String,
+ ) -> ResultFuture<(MailboxHash, HashMap<MailboxHash, Mailbox>)>;
fn delete_mailbox(
&mut self,
- _mailbox_hash: MailboxHash,
- ) -> ResultFuture<HashMap<MailboxHash, Mailbox>> {
- Err(MeliError::new("Deleting mailbox is currently unimplemented.").set_kind(ErrorKind::NotImplemented))
- }
+ mailbox_hash: MailboxHash,
+ ) -> ResultFuture<HashMap<MailboxHash, Mailbox>>;
fn set_mailbox_subscription(
&mut self,
- _mailbox_hash: MailboxHash,
- _val: bool,
- ) -> ResultFuture<()> {
- Err(MeliError::new("Setting mailbox subscription is currently unimplemented.").set_kind(ErrorKind::NotImplemented))
- }
+ mailbox_hash: MailboxHash,
+ val: bool,
+ ) -> ResultFuture<()>;
fn rename_mailbox(
&mut self,
- _mailbox_hash: MailboxHash,
- _new_path: String,
- ) -> ResultFuture<Mailbox> {
- Err(MeliError::new("Renaming mailbox is currently unimplemented.").set_kind(ErrorKind::NotImplemented))
- }
+ mailbox_hash: MailboxHash,
+ new_path: String,
+ ) -> ResultFuture<Mailbox>;
fn set_mailbox_permissions(
&mut self,
- _mailbox_hash: MailboxHash,
- _val: MailboxPermissions,
- ) -> ResultFuture<()> {
- Err(MeliError::new("Setting mailbox permissions is currently unimplemented.").set_kind(ErrorKind::NotImplemented))
- }
+ mailbox_hash: MailboxHash,
+ val: MailboxPermissions,
+ ) -> ResultFuture<()>;
fn search(
&self,
- _query: crate::search::Query,
- _mailbox_hash: Option<MailboxHash>,
- ) -> ResultFuture<SmallVec<[EnvelopeHash; 512]>> {
- Err(MeliError::new("Search is currently unimplemented.").set_kind(ErrorKind::NotImplemented))
- }
+ query: crate::search::Query,
+ mailbox_hash: Option<MailboxHash>,
+ ) -> ResultFuture<SmallVec<[EnvelopeHash; 512]>>;
fn submit(
&self,
@@ -448,7 +436,8 @@ pub trait MailBackend: ::std::fmt::Debug + Send + Sync {
_mailbox_hash: Option<MailboxHash>,
_flags: Option<Flag>,
) -> ResultFuture<()> {
- Err(MeliError::new("Not supported in this backend.").set_kind(ErrorKind::NotSupported))
+ Err(MeliError::new("Submission not supported in this backend.")
+ .set_kind(ErrorKind::NotSupported))
}
}
@@ -634,7 +623,7 @@ impl std::fmt::Display for MailboxPermissions {
}
}
-#[derive(Debug, Clone, PartialEq)]
+#[derive(Debug, Clone, PartialEq, Eq)]
pub struct EnvelopeHashBatch {
pub first: EnvelopeHash,
pub rest: SmallVec<[EnvelopeHash; 64]>,
diff --git a/melib/src/backends/imap/managesieve.rs b/melib/src/backends/imap/managesieve.rs
index 67c036c6..d60f2238 100644
--- a/melib/src/backends/imap/managesieve.rs
+++ b/melib/src/backends/imap/managesieve.rs
@@ -349,10 +349,8 @@ impl ManageSieveConnection {
ManageSieveResponse::Ok { .. } => Ok(()),
ManageSieveResponse::NoBye { code, message } => Err(format!(
"Could not upload script: {} {}",
- code.map(|b| String::from_utf8_lossy(b)).unwrap_or_default(),
- message
- .map(|b| String::from_utf8_lossy(b))
- .unwrap_or_default()
+ code.map(String::from_utf8_lossy).unwrap_or_default(),
+ message.map(String::from_utf8_lossy).unwrap_or_default()
)
.into()),
}
@@ -386,10 +384,8 @@ impl ManageSieveConnection {
ManageSieveResponse::Ok { .. } => Ok(()),
ManageSieveResponse::NoBye { code, message } => Err(format!(
"Checkscript reply: {} {}",
- code.map(|b| String::from_utf8_lossy(b)).unwrap_or_default(),
- message
- .map(|b| String::from_utf8_lossy(b))
- .unwrap_or_default()
+ code.map(String::from_utf8_lossy).unwrap_or_default(),
+ message.map(String::from_utf8_lossy).unwrap_or_default()
)
.into()),
}
@@ -409,10 +405,8 @@ impl ManageSieveConnection {
ManageSieveResponse::Ok { .. } => Ok(()),
ManageSieveResponse::NoBye { code, message } => Err(format!(
"Could not set active script: {} {}",
- code.map(|b| String::from_utf8_lossy(b)).unwrap_or_default(),
- message
- .map(|b| String::from_utf8_lossy(b))
- .unwrap_or_default()
+ code.map(String::from_utf8_lossy).unwrap_or_default(),
+ message.map(String::from_utf8_lossy).unwrap_or_default()
)
.into()),
}
@@ -432,10 +426,8 @@ impl ManageSieveConnection {
{
return Err(format!(
"Could not set active script: {} {}",
- code.map(|b| String::from_utf8_lossy(b)).unwrap_or_default(),
- message
- .map(|b| String::from_utf8_lossy(b))
- .unwrap_or_default()
+ code.map(String::from_utf8_lossy).unwrap_or_default(),
+ message.map(String::from_utf8_lossy).unwrap_or_default()
)
.into());
}
@@ -460,10 +452,8 @@ impl ManageSieveConnection {
ManageSieveResponse::Ok { .. } => Ok(()),
ManageSieveResponse::NoBye { code, message } => Err(format!(
"Could not delete script: {} {}",
- code.map(|b| String::from_utf8_lossy(b)).unwrap_or_default(),
- message
- .map(|b| String::from_utf8_lossy(b))
- .unwrap_or_default()
+ code.map(String::from_utf8_lossy).unwrap_or_default(),
+ message.map(String::from_utf8_lossy).unwrap_or_default()
)
.into()),
}
diff --git a/melib/src/backends/jmap.rs b/melib/src/backends/jmap.rs
index 12fe8ffe..4b03e404 100644
--- a/melib/src/backends/jmap.rs
+++ b/melib/src/backends/jmap.rs
@@ -586,14 +586,18 @@ impl MailBackend for JmapType {
_mailbox_hash: MailboxHash,
_new_path: String,
) -> ResultFuture<Mailbox> {
- Err(MeliError::new("Renaming mailbox is currently unimplemented for jmap backend."))
+ Err(MeliError::new(
+ "Renaming mailbox is currently unimplemented for jmap backend.",
+ ))
}
fn create_mailbox(
&mut self,
_path: String,
) -> ResultFuture<(MailboxHash, HashMap<MailboxHash, Mailbox>)> {
- Err(MeliError::new("Creating mailbox is currently unimplemented for jmap backend."))
+ Err(MeliError::new(
+ "Creating mailbox is currently unimplemented for jmap backend.",
+ ))
}
fn copy_messages(
@@ -860,7 +864,9 @@ impl MailBackend for JmapType {
_env_hashes: EnvelopeHashBatch,
_mailbox_hash: MailboxHash,
) -> ResultFuture<()> {
- Err(MeliError::new("Deleting messages is currently unimplemented for jmap backend."))
+ Err(MeliError::new(
+ "Deleting messages is currently unimplemented for jmap backend.",
+ ))
}
}
diff --git a/melib/src/backends/maildir/backend.rs b/melib/src/backends/maildir/backend.rs
index 405a1dfb..55b6ca47 100644
--- a/melib/src/backends/maildir/backend.rs
+++ b/melib/src/backends/maildir/backend.rs
@@ -1047,7 +1047,9 @@ impl MailBackend for MaildirType {
&mut self,
_mailbox_hash: MailboxHash,
) -> ResultFuture<HashMap<MailboxHash, Mailbox>> {
- Err(MeliError::new("Deleting messages is currently unimplemented for maildir backend."))
+ Err(MeliError::new(
+ "Deleting mailboxes is currently unimplemented for maildir backend.",
+ ))
}
fn set_mailbox_subscription(
@@ -1055,7 +1057,9 @@ impl MailBackend for MaildirType {
_mailbox_hash: MailboxHash,
_val: bool,
) -> ResultFuture<()> {
- Err(MeliError::new("Mailbox description is currently unimplemented for maildir backend."))
+ Err(MeliError::new(
+ "Mailbox subscriptions are not possible for the maildir backend.",
+ ))
}
fn rename_mailbox(
@@ -1063,7 +1067,9 @@ impl MailBackend for MaildirType {
_mailbox_hash: MailboxHash,
_new_path: String,
) -> ResultFuture<Mailbox> {
- Err(MeliError::new("Renaming mailbox is currently unimplemented for maildir backend."))
+ Err(MeliError::new(
+ "Renaming mailboxes is currently unimplemented for maildir backend.",
+ ))
}
fn set_mailbox_permissions(
@@ -1071,7 +1077,20 @@ impl MailBackend for MaildirType {
_mailbox_hash: MailboxHash,
_val: crate::backends::MailboxPermissions,
) -> ResultFuture<()> {
- Err(MeliError::new("Setting mailbox permissions is currently unimplemented for maildir backend."))
+ Err(MeliError::new(
+ "Setting mailbox permissions is not possible for the maildir backend.",
+ ))
+ }
+
+ fn search(
+ &self,
+ _query: crate::search::Query,
+ _mailbox_hash: Option<MailboxHash>,
+ ) -> ResultFuture<SmallVec<[EnvelopeHash; 512]>> {
+ Err(
+ MeliError::new("Search is unimplemented for the maildir backend.")
+ .set_kind(ErrorKind::NotImplemented),
+ )
}
fn as_any(&self) -> &dyn Any {
diff --git a/melib/src/backends/mbox.rs b/melib/src/backends/mbox.rs
index bffbf025..9b08063b 100644
--- a/melib/src/backends/mbox.rs
+++ b/melib/src/backends/mbox.rs
@@ -126,13 +126,13 @@ use crate::collection::Collection;
use crate::conf::AccountSettings;
use crate::email::parser::BytesExt;
use crate::email::*;
-use crate::error::{MeliError, Result};
+use crate::error::{ErrorKind, MeliError, Result};
use crate::get_path_hash;
use crate::shellexpand::ShellExpandTrait;
use nom::bytes::complete::tag;
use nom::character::complete::digit1;
use nom::combinator::map_res;
-use nom::{self, error::Error as NomError, error::ErrorKind, IResult};
+use nom::{self, error::Error as NomError, error::ErrorKind as NomErrorKind, IResult};
extern crate notify;
use self::notify::{watcher, DebouncedEvent, RecursiveMode, Watcher};
@@ -494,7 +494,7 @@ impl MboxFormat {
debug!("Could not parse mail {:?}", err);
Err(nom::Err::Error(NomError {
input,
- code: ErrorKind::Tag,
+ code: NomErrorKind::Tag,
}))
}
}
@@ -541,7 +541,7 @@ impl MboxFormat {
debug!("Could not parse mail at {:?}", err);
Err(nom::Err::Error(NomError {
input,
- code: ErrorKind::Tag,
+ code: NomErrorKind::Tag,
}))
}
}
@@ -598,7 +598,7 @@ impl MboxFormat {
debug!("Could not parse mail {:?}", err);
Err(nom::Err::Error(NomError {
input,
- code: ErrorKind::Tag,
+ code: NomErrorKind::Tag,
}))
}
}
@@ -645,7 +645,7 @@ impl MboxFormat {
debug!("Could not parse mail {:?}", err);
Err(nom::Err::Error(NomError {
input,
- code: ErrorKind::Tag,
+ code: NomErrorKind::Tag,
}))
}
}
@@ -739,7 +739,7 @@ pub fn mbox_parse(
if input.is_empty() {
return Err(nom::Err::Error(NomError {
input,
- code: ErrorKind::Tag,
+ code: NomErrorKind::Tag,
}));
}
let mut offset = 0;
@@ -963,7 +963,9 @@ impl MailBackend for MboxType {
}
fn refresh(&mut self, _mailbox_hash: MailboxHash) -> ResultFuture<()> {
- Err(MeliError::new("Refreshing is currently unimplemented for mbox backend."))
+ Err(MeliError::new(
+ "Refreshing is currently unimplemented for mbox backend.",
+ ))
}
fn watch(&self) -> ResultFuture<()> {
@@ -1154,7 +1156,9 @@ impl MailBackend for MboxType {
_destination_mailbox_hash: MailboxHash,
_move_: bool,
) -> ResultFuture<()> {
- Err(MeliError::new("Copying messages is currently unimplemented for mbox backend"))
+ Err(MeliError::new(
+ "Copying messages is currently unimplemented for mbox backend",
+ ))
}
fn set_flags(
@@ -1163,7 +1167,9 @@ impl MailBackend for MboxType {
_mailbox_hash: MailboxHash,
_flags: SmallVec<[(std::result::Result<Flag, String>, bool); 8]>,
) -> ResultFuture<()> {
- Err(MeliError::new("Settings flags is currently unimplemented for mbox backend"))
+ Err(MeliError::new(
+ "Settings flags is currently unimplemented for mbox backend",
+ ))
}
fn delete_messages(
@@ -1171,7 +1177,9 @@ impl MailBackend for MboxType {
_env_hashes: EnvelopeHashBatch,
_mailbox_hash: MailboxHash,
) -> ResultFuture<()> {
- Err(MeliError::new("Deleting messages is currently unimplemented for mbox backend"))
+ Err(MeliError::new(
+ "Deleting messages is currently unimplemented for mbox backend",
+ ))
}
fn save(
@@ -1180,7 +1188,9 @@ impl MailBackend for MboxType {
_mailbox_hash: MailboxHash,
_flags: Option<Flag>,
) -> ResultFuture<()> {
- Err(MeliError::new("Saving messages is currently unimplemented for mbox backend"))
+ Err(MeliError::new(
+ "Saving messages is currently unimplemented for mbox backend",
+ ))
}
fn as_any(&self) -> &dyn Any {
@@ -1194,6 +1204,66 @@ impl MailBackend for MboxType {
fn collection(&self) -> Collection {
self.collection.clone()
}
+
+ fn delete_mailbox(
+ &mut self,
+ _mailbox_hash: MailboxHash,
+ ) -> ResultFuture<HashMap<MailboxHash, Mailbox>> {
+ Err(MeliError::new(
+ "Deleting mailboxes is currently unimplemented for mbox backend.",
+ ))
+ }
+
+ fn set_mailbox_subscription(
+ &mut self,
+ _mailbox_hash: MailboxHash,
+ _val: bool,
+ ) -> ResultFuture<()> {
+ Err(MeliError::new(
+ "Mailbox subscriptions are not possible for the mbox backend.",
+ ))
+ }
+
+ fn rename_mailbox(
+ &mut self,
+ _mailbox_hash: MailboxHash,
+ _new_path: String,
+ ) -> ResultFuture<Mailbox> {
+ Err(MeliError::new(
+ "Renaming mailboxes is currently unimplemented for mbox backend.",
+ ))
+ }
+
+ fn set_mailbox_permissions(
+ &mut self,
+ _mailbox_hash: MailboxHash,
+ _val: crate::backends::MailboxPermissions,
+ ) -> ResultFuture<()> {
+ Err(MeliError::new(
+ "Setting mailbox permissions is not possible for the mbox backend.",
+ ))
+ }
+
+ fn search(
+ &self,
+ _query: crate::search::Query,
+ _mailbox_hash: Option<MailboxHash>,
+ ) -> ResultFuture<SmallVec<[EnvelopeHash; 512]>> {
+ Err(
+ MeliError::new("Search is unimplemented for the mbox backend.")
+ .set_kind(ErrorKind::NotImplemented),
+ )
+ }
+
+ fn create_mailbox(
+ &mut self,
+ _new_path: String,
+ ) -> ResultFuture<(MailboxHash, HashMap<MailboxHash, Mailbox>)> {
+ Err(
+ MeliError::new("Creating mailboxes is unimplemented for the mbox backend.")
+ .set_kind(ErrorKind::NotImplemented),
+ )
+ }
}
macro_rules! get_conf_val {
diff --git a/melib/src/backends/nntp.rs b/melib/src/backends/nntp.rs
index a6c38864..695242f8 100644
--- a/melib/src/backends/nntp.rs
+++ b/melib/src/backends/nntp.rs
@@ -367,7 +367,10 @@ impl MailBackend for NntpType {
}
fn watch(&self) -> ResultFuture<()> {
- Err(MeliError::new("Watching is currently uniplemented for nntp backend").set_kind(ErrorKind::NotImplemented))
+ Err(
+ MeliError::new("Watching is currently uniplemented for nntp backend")
+ .set_kind(ErrorKind::NotImplemented),
+ )
}
fn operation(&self, env_hash: EnvelopeHash) -> Result<Box<dyn BackendOp>> {
@@ -440,14 +443,18 @@ impl MailBackend for NntpType {
&mut self,
_path: String,
) -> ResultFuture<(MailboxHash, HashMap<MailboxHash, Mailbox>)> {
- Err(MeliError::new("Creating mailbox is currently unimplemented for nntp backend."))
+ Err(MeliError::new(
+ "Creating mailbox is currently unimplemented for nntp backend.",
+ ))
}
fn delete_mailbox(
&mut self,
_mailbox_hash: MailboxHash,
) -> ResultFuture<HashMap<MailboxHash, Mailbox>> {
- Err(MeliError::new("Deleting a mailbox is currently unimplemented for nntp backend."))
+ Err(MeliError::new(
+ "Deleting a mailbox is currently unimplemented for nntp backend.",
+ ))
}
fn set_mailbox_subscription(
@@ -455,7 +462,9 @@ impl MailBackend for NntpType {
_mailbox_hash: MailboxHash,
_new_val: bool,
) -> ResultFuture<()> {
- Err(MeliError::new("Setting mailbox description is currently unimplemented for nntp backend."))
+ Err(MeliError::new(
+ "Setting mailbox description is currently unimplemented for nntp backend.",
+ ))
}
fn rename_mailbox(
@@ -463,7 +472,9 @@ impl MailBackend for NntpType {
_mailbox_hash: MailboxHash,
_new_path: String,
) -> ResultFuture<Mailbox> {
- Err(MeliError::new("Renaming mailbox is currently unimplemented for nntp backend."))
+ Err(MeliError::new(
+ "Renaming mailbox is currently unimplemented for nntp backend.",
+ ))
}
fn set_mailbox_permissions(
@@ -471,7 +482,9 @@ impl MailBackend for NntpType {
_mailbox_hash: MailboxHash,
_val: crate::backends::MailboxPermissions,
) -> ResultFuture<()> {
- Err(MeliError::new("Setting mailbox permissions is currently unimplemented for nntp backend."))
+ Err(MeliError::new(
+ "Setting mailbox permissions is currently unimplemented for nntp backend.",
+ ))
}
fn search(
@@ -479,7 +492,9 @@ impl MailBackend for NntpType {
_query: crate::search::Query,
_mailbox_hash: Option<MailboxHash>,
) -> ResultFuture<SmallVec<[EnvelopeHash; 512]>> {
- Err(MeliError::new("Searching is currently unimplemented for nntp backend."))
+ Err(MeliError::new(
+ "Searching is currently unimplemented for nntp backend.",
+ ))
}
fn submit(
diff --git a/melib/src/backends/notmuch.rs b/melib/src/backends/notmuch.rs
index 948a1c51..16dd6508 100644
--- a/melib/src/backends/notmuch.rs
+++ b/melib/src/backends/notmuch.rs
@@ -754,7 +754,9 @@ impl MailBackend for NotmuchDb {
_destination_mailbox_hash: MailboxHash,
_move_: bool,
) -> ResultFuture<()> {
- Err(MeliError::new("Copying messages is currently unimplemented for notmuch backend"))
+ Err(MeliError::new(
+ "Copying messages is currently unimplemented for notmuch backend",
+ ))
}
fn set_flags(
@@ -874,7 +876,9 @@ impl MailBackend for NotmuchDb {
_env_hashes: EnvelopeHashBatch,
_mailbox_hash: MailboxHash,
) -> ResultFuture<()> {
- Err(MeliError::new("Deleting messages is currently unimplemented for notmuch backend"))
+ Err(MeliError::new(
+ "Deleting messages is currently unimplemented for notmuch backend",
+ ))
}
fn search(
@@ -925,6 +929,55 @@ impl MailBackend for NotmuchDb {
fn as_any_mut(&mut self) -> &mut dyn Any {
self
}
+
+ fn delete_mailbox(
+ &mut self,
+ _mailbox_hash: MailboxHash,
+ ) -> ResultFuture<HashMap<MailboxHash, Mailbox>> {
+ Err(MeliError::new(
+ "Deleting mailboxes is currently unimplemented for notmuch backend.",
+ ))
+ }
+
+ fn set_mailbox_subscription(
+ &mut self,
+ _mailbox_hash: MailboxHash,
+ _val: bool,
+ ) -> ResultFuture<()> {
+ Err(MeliError::new(
+ "Mailbox subscriptions are not possible for the notmuch backend.",
+ ))
+ }
+
+ fn rename_mailbox(
+ &mut self,
+ _mailbox_hash: MailboxHash,
+ _new_path: String,
+ ) -> ResultFuture<Mailbox> {
+ Err(MeliError::new(
+ "Renaming mailboxes is currently unimplemented for notmuch backend.",
+ ))
+ }
+
+ fn set_mailbox_permissions(
+ &mut self,
+ _mailbox_hash: MailboxHash,
+ _val: crate::backends::MailboxPermissions,
+ ) -> ResultFuture<()> {
+ Err(MeliError::new(
+ "Setting mailbox permissions is not possible for the notmuch backend.",
+ ))
+ }
+
+ fn create_mailbox(
+ &mut self,
+ _new_path: String,
+ ) -> ResultFuture<(MailboxHash, HashMap<MailboxHash, Mailbox>)> {
+ Err(
+ MeliError::new("Creating mailboxes is unimplemented for the notmuch backend.")
+ .set_kind(ErrorKind::NotImplemented),
+ )
+ }
}
#[derive(Debug)]
diff --git a/melib/src/conf.rs b/melib/src/conf.rs
index 7047215c..5ce85c71 100644
--- a/melib/src/conf.rs
+++ b/melib/src/conf.rs
@@ -172,7 +172,7 @@ mod strings {
named_unit_variant!(ask);
}
-#[derive(Copy, Debug, Clone, PartialEq)]
+#[derive(Copy, Debug, Clone, PartialEq, Eq)]
pub enum ToggleFlag {
Unset,
InternalVal(bool),
diff --git a/melib/src/email/list_management.rs b/melib/src/email/list_management.rs
index 3ecbb202..b0e07d82 100644
--- a/melib/src/email/list_management.rs
+++ b/melib/src/email/list_management.rs
@@ -25,7 +25,7 @@ use super::Envelope;
use smallvec::SmallVec;
use std::convert::From;
-#[derive(Debug, PartialEq, Clone, Copy)]
+#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum ListAction<'a> {
Url(&'a [u8]),
Email(&'a [u8]),
diff --git a/melib/src/error.rs b/melib/src/error.rs
index 06debaac..40a98550 100644
--- a/melib/src/error.rs
+++ b/melib/src/error.rs
@@ -34,7 +34,7 @@ use std::sync::Arc;
pub type Result<T> = result::Result<T, MeliError>;
-#[derive(Debug, Copy, PartialEq, Clone)]
+#[derive(Debug, Copy, PartialEq, Eq, Clone)]
pub enum NetworkErrorKind {
/// Unspecified
None,
@@ -312,7 +312,7 @@ impl From<isahc::http::StatusCode> for NetworkErrorKind {
}
}
-#[derive(Debug, Copy, PartialEq, Clone)]
+#[derive(Debug, Copy, PartialEq, Eq, Clone)]
pub enum ErrorKind {
None,
External,
diff --git a/melib/src/gpgme/bindings.rs b/melib/src/gpgme/bindings.rs
index ddb61b0e..4883b899 100644
--- a/melib/src/gpgme/bindings.rs
+++ b/melib/src/gpgme/bindings.rs
@@ -24,6 +24,8 @@
#![allow(non_snake_case)]
#![allow(unused)]
#![allow(dead_code)]
+#![allow(clippy::useless_transmute)]
+#![allow(clippy::too_many_arguments)]
use libc::{off_t, time_t, FILE};
/* automatically generated by rust-bindgen */
diff --git a/melib/src/gpgme/mod.rs b/melib/src/gpgme/mod.rs
index 9d8c4703..4a5926b0 100644
--- a/melib/src/gpgme/mod.rs
+++ b/melib/src/gpgme/mod.rs
@@ -64,7 +64,7 @@ mod bindings;
use bindings::*;
mod io;
-#[derive(Debug, Clone, Copy, PartialEq)]
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum GpgmeFlag {
///"auto-key-retrieve"
AutoKeyRetrieve,
@@ -1314,12 +1314,14 @@ impl std::fmt::Debug for Key {
}
}
-impl std::cmp::PartialEq for Key {
+impl PartialEq for Key {
fn eq(&self, other: &Key) -> bool {
self.fingerprint() == other.fingerprint()
}
}
+impl Eq for Key {}
+
impl Drop for Key {
#[inline]
fn drop(&mut self) {
diff --git a/melib/src/lib.rs b/melib/src/lib.rs
index 7aef047c..e1aa4cf1 100644
--- a/melib/src/lib.rs
+++ b/melib/src/lib.rs
@@ -240,7 +240,7 @@ pub mod shellexpand {
.components()
.last()
.map(|c| c.as_os_str())
- .unwrap_or(OsStr::from_bytes(b""));
+ .unwrap_or_else(|| OsStr::from_bytes(b""));
let prefix = if let Some(p) = self.parent() {
p
} else {
diff --git a/melib/src/smtp.rs b/melib/src/smtp.rs
index b9643dd1..589bdfaa 100644
--- a/melib/src/smtp.rs
+++ b/melib/src/smtp.rs
@@ -88,7 +88,7 @@ use std::net::TcpStream;
use std::process::Command;
/// Kind of server security (StartTLS/TLS/None) the client should attempt
-#[derive(Debug, Copy, PartialEq, Clone, Serialize, Deserialize)]
+#[derive(Debug, Copy, PartialEq, Eq, Clone, Serialize, Deserialize)]
#[serde(tag = "type")]
pub enum SmtpSecurity {
#[serde(alias = "starttls", alias = "STARTTLS")]
@@ -119,7 +119,7 @@ impl Default for SmtpSecurity {
}
/// Source of user's password for SMTP authentication
-#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
+#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
#[serde(tag = "type", content = "value")]
pub enum Password {
#[serde(alias = "raw")]
@@ -129,7 +129,7 @@ pub enum Password {
}
/// Kind of server authentication the client should attempt
-#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
+#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
#[serde(tag = "type")]
pub enum SmtpAuth {
#[serde(alias = "none")]
@@ -152,7 +152,7 @@ pub enum SmtpAuth {
// md5, sasl, etc
}
-#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Default)]
+#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize, Default)]
pub struct SmtpAuthType {
plain: bool,
login: bool,
@@ -761,7 +761,7 @@ impl SmtpConnection {
pub type ExpectedReplyCode = Option<(ReplyCode, &'static [ReplyCode])>;
/// Recognized kinds of SMTP reply codes
-#[derive(Debug, Copy, Clone, PartialEq)]
+#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum ReplyCode {
///System status, or system help reply
_211,
diff --git a/melib/src/text_processing/types.rs b/melib/src/text_processing/types.rs
index 1912e762..b088b79d 100644
--- a/melib/src/text_processing/types.rs
+++ b/melib/src/text_processing/types.rs
@@ -20,7 +20,7 @@
*/
#[allow(clippy::upper_case_acronyms)]
-#[derive(Debug, Copy, Clone, PartialEq)]
+#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum LineBreakClass {
BK,
CM,
@@ -123,7 +123,7 @@ impl From<&str> for LineBreakClass {
}
}
-#[derive(PartialEq, Debug, Copy, Clone)]
+#[derive(PartialEq, Eq, Debug, Copy, Clone)]
pub enum Reflow {
No,
All,
diff --git a/melib/src/thread.rs b/melib/src/thread.rs
index 69e47705..76ed82d8 100644
--- a/melib/src/thread.rs
+++ b/melib/src/thread.rs
@@ -452,13 +452,13 @@ impl SubjectPrefix for &str {
/* Sorting states. */
-#[derive(Debug, Clone, PartialEq, Copy, Deserialize, Serialize)]
+#[derive(Debug, Clone, PartialEq, Eq, Copy, Deserialize, Serialize)]
pub enum SortOrder {
Asc,
Desc,
}
-#[derive(Debug, Clone, PartialEq, Copy, Deserialize, Serialize)]
+#[derive(Debug, Clone, PartialEq, Eq, Copy, Deserialize, Serialize)]
pub enum SortField {
Subject,
Date,
@@ -550,6 +550,10 @@ impl Thread {
self.attachments > 0
}
+ pub fn is_empty(&self) -> bool {
+ self.len == 0
+ }
+
pub fn set_snoozed(&mut self, val: bool) {
self.snoozed = val;
}
@@ -654,6 +658,8 @@ impl PartialEq for ThreadNode {
}
}
+impl Eq for ThreadNode {}
+
impl Threads {
pub fn is_snoozed(&self, h: ThreadNodeHash) -> bool {
self.thread_ref(self.thread_nodes[&h].group).snoozed()
@@ -1442,6 +1448,10 @@ impl Threads {
self.hash_set.len()
}
+ pub fn is_empty(&self) -> bool {
+ self.hash_set.is_empty()
+ }
+
pub fn root_len(&self) -> usize {
self.tree_index.read().unwrap().len()
}