melib: fix clippy lints

pull/168/head
Manos Pitsidianakis 2022-11-14 19:14:19 +02:00
parent ded9adde61
commit bd22f986f0
17 changed files with 252 additions and 96 deletions

View File

@ -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 { pub struct AddressBook {
display_name: String, display_name: String,
created: UnixTimestamp, created: UnixTimestamp,
@ -64,7 +64,7 @@ pub struct AddressBook {
pub cards: HashMap<CardId, Card>, pub cards: HashMap<CardId, Card>,
} }
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] #[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
pub struct Card { pub struct Card {
id: CardId, id: CardId,
title: String, title: String,

View File

@ -398,49 +398,37 @@ pub trait MailBackend: ::std::fmt::Debug + Send + Sync {
fn create_mailbox( fn create_mailbox(
&mut self, &mut self,
_path: String, path: String,
) -> ResultFuture<(MailboxHash, HashMap<MailboxHash, Mailbox>)> { ) -> ResultFuture<(MailboxHash, HashMap<MailboxHash, Mailbox>)>;
Err(MeliError::new("Creating mailbox is currently unimplemented.").set_kind(ErrorKind::NotImplemented))
}
fn delete_mailbox( fn delete_mailbox(
&mut self, &mut self,
_mailbox_hash: MailboxHash, mailbox_hash: MailboxHash,
) -> ResultFuture<HashMap<MailboxHash, Mailbox>> { ) -> ResultFuture<HashMap<MailboxHash, Mailbox>>;
Err(MeliError::new("Deleting mailbox is currently unimplemented.").set_kind(ErrorKind::NotImplemented))
}
fn set_mailbox_subscription( fn set_mailbox_subscription(
&mut self, &mut self,
_mailbox_hash: MailboxHash, mailbox_hash: MailboxHash,
_val: bool, val: bool,
) -> ResultFuture<()> { ) -> ResultFuture<()>;
Err(MeliError::new("Setting mailbox subscription is currently unimplemented.").set_kind(ErrorKind::NotImplemented))
}
fn rename_mailbox( fn rename_mailbox(
&mut self, &mut self,
_mailbox_hash: MailboxHash, mailbox_hash: MailboxHash,
_new_path: String, new_path: String,
) -> ResultFuture<Mailbox> { ) -> ResultFuture<Mailbox>;
Err(MeliError::new("Renaming mailbox is currently unimplemented.").set_kind(ErrorKind::NotImplemented))
}
fn set_mailbox_permissions( fn set_mailbox_permissions(
&mut self, &mut self,
_mailbox_hash: MailboxHash, mailbox_hash: MailboxHash,
_val: MailboxPermissions, val: MailboxPermissions,
) -> ResultFuture<()> { ) -> ResultFuture<()>;
Err(MeliError::new("Setting mailbox permissions is currently unimplemented.").set_kind(ErrorKind::NotImplemented))
}
fn search( fn search(
&self, &self,
_query: crate::search::Query, query: crate::search::Query,
_mailbox_hash: Option<MailboxHash>, mailbox_hash: Option<MailboxHash>,
) -> ResultFuture<SmallVec<[EnvelopeHash; 512]>> { ) -> ResultFuture<SmallVec<[EnvelopeHash; 512]>>;
Err(MeliError::new("Search is currently unimplemented.").set_kind(ErrorKind::NotImplemented))
}
fn submit( fn submit(
&self, &self,
@ -448,7 +436,8 @@ pub trait MailBackend: ::std::fmt::Debug + Send + Sync {
_mailbox_hash: Option<MailboxHash>, _mailbox_hash: Option<MailboxHash>,
_flags: Option<Flag>, _flags: Option<Flag>,
) -> ResultFuture<()> { ) -> 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 struct EnvelopeHashBatch {
pub first: EnvelopeHash, pub first: EnvelopeHash,
pub rest: SmallVec<[EnvelopeHash; 64]>, pub rest: SmallVec<[EnvelopeHash; 64]>,

View File

@ -349,10 +349,8 @@ impl ManageSieveConnection {
ManageSieveResponse::Ok { .. } => Ok(()), ManageSieveResponse::Ok { .. } => Ok(()),
ManageSieveResponse::NoBye { code, message } => Err(format!( ManageSieveResponse::NoBye { code, message } => Err(format!(
"Could not upload script: {} {}", "Could not upload script: {} {}",
code.map(|b| String::from_utf8_lossy(b)).unwrap_or_default(), code.map(String::from_utf8_lossy).unwrap_or_default(),
message message.map(String::from_utf8_lossy).unwrap_or_default()
.map(|b| String::from_utf8_lossy(b))
.unwrap_or_default()
) )
.into()), .into()),
} }
@ -386,10 +384,8 @@ impl ManageSieveConnection {
ManageSieveResponse::Ok { .. } => Ok(()), ManageSieveResponse::Ok { .. } => Ok(()),
ManageSieveResponse::NoBye { code, message } => Err(format!( ManageSieveResponse::NoBye { code, message } => Err(format!(
"Checkscript reply: {} {}", "Checkscript reply: {} {}",
code.map(|b| String::from_utf8_lossy(b)).unwrap_or_default(), code.map(String::from_utf8_lossy).unwrap_or_default(),
message message.map(String::from_utf8_lossy).unwrap_or_default()
.map(|b| String::from_utf8_lossy(b))
.unwrap_or_default()
) )
.into()), .into()),
} }
@ -409,10 +405,8 @@ impl ManageSieveConnection {
ManageSieveResponse::Ok { .. } => Ok(()), ManageSieveResponse::Ok { .. } => Ok(()),
ManageSieveResponse::NoBye { code, message } => Err(format!( ManageSieveResponse::NoBye { code, message } => Err(format!(
"Could not set active script: {} {}", "Could not set active script: {} {}",
code.map(|b| String::from_utf8_lossy(b)).unwrap_or_default(), code.map(String::from_utf8_lossy).unwrap_or_default(),
message message.map(String::from_utf8_lossy).unwrap_or_default()
.map(|b| String::from_utf8_lossy(b))
.unwrap_or_default()
) )
.into()), .into()),
} }
@ -432,10 +426,8 @@ impl ManageSieveConnection {
{ {
return Err(format!( return Err(format!(
"Could not set active script: {} {}", "Could not set active script: {} {}",
code.map(|b| String::from_utf8_lossy(b)).unwrap_or_default(), code.map(String::from_utf8_lossy).unwrap_or_default(),
message message.map(String::from_utf8_lossy).unwrap_or_default()
.map(|b| String::from_utf8_lossy(b))
.unwrap_or_default()
) )
.into()); .into());
} }
@ -460,10 +452,8 @@ impl ManageSieveConnection {
ManageSieveResponse::Ok { .. } => Ok(()), ManageSieveResponse::Ok { .. } => Ok(()),
ManageSieveResponse::NoBye { code, message } => Err(format!( ManageSieveResponse::NoBye { code, message } => Err(format!(
"Could not delete script: {} {}", "Could not delete script: {} {}",
code.map(|b| String::from_utf8_lossy(b)).unwrap_or_default(), code.map(String::from_utf8_lossy).unwrap_or_default(),
message message.map(String::from_utf8_lossy).unwrap_or_default()
.map(|b| String::from_utf8_lossy(b))
.unwrap_or_default()
) )
.into()), .into()),
} }

View File

@ -586,14 +586,18 @@ impl MailBackend for JmapType {
_mailbox_hash: MailboxHash, _mailbox_hash: MailboxHash,
_new_path: String, _new_path: String,
) -> ResultFuture<Mailbox> { ) -> 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( fn create_mailbox(
&mut self, &mut self,
_path: String, _path: String,
) -> ResultFuture<(MailboxHash, HashMap<MailboxHash, Mailbox>)> { ) -> 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( fn copy_messages(
@ -860,7 +864,9 @@ impl MailBackend for JmapType {
_env_hashes: EnvelopeHashBatch, _env_hashes: EnvelopeHashBatch,
_mailbox_hash: MailboxHash, _mailbox_hash: MailboxHash,
) -> ResultFuture<()> { ) -> ResultFuture<()> {
Err(MeliError::new("Deleting messages is currently unimplemented for jmap backend.")) Err(MeliError::new(
"Deleting messages is currently unimplemented for jmap backend.",
))
} }
} }

View File

@ -1047,7 +1047,9 @@ impl MailBackend for MaildirType {
&mut self, &mut self,
_mailbox_hash: MailboxHash, _mailbox_hash: MailboxHash,
) -> ResultFuture<HashMap<MailboxHash, Mailbox>> { ) -> 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( fn set_mailbox_subscription(
@ -1055,7 +1057,9 @@ impl MailBackend for MaildirType {
_mailbox_hash: MailboxHash, _mailbox_hash: MailboxHash,
_val: bool, _val: bool,
) -> ResultFuture<()> { ) -> 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( fn rename_mailbox(
@ -1063,7 +1067,9 @@ impl MailBackend for MaildirType {
_mailbox_hash: MailboxHash, _mailbox_hash: MailboxHash,
_new_path: String, _new_path: String,
) -> ResultFuture<Mailbox> { ) -> 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( fn set_mailbox_permissions(
@ -1071,7 +1077,20 @@ impl MailBackend for MaildirType {
_mailbox_hash: MailboxHash, _mailbox_hash: MailboxHash,
_val: crate::backends::MailboxPermissions, _val: crate::backends::MailboxPermissions,
) -> ResultFuture<()> { ) -> 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 { fn as_any(&self) -> &dyn Any {

View File

@ -126,13 +126,13 @@ use crate::collection::Collection;
use crate::conf::AccountSettings; use crate::conf::AccountSettings;
use crate::email::parser::BytesExt; use crate::email::parser::BytesExt;
use crate::email::*; use crate::email::*;
use crate::error::{MeliError, Result}; use crate::error::{ErrorKind, MeliError, Result};
use crate::get_path_hash; use crate::get_path_hash;
use crate::shellexpand::ShellExpandTrait; use crate::shellexpand::ShellExpandTrait;
use nom::bytes::complete::tag; use nom::bytes::complete::tag;
use nom::character::complete::digit1; use nom::character::complete::digit1;
use nom::combinator::map_res; 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; extern crate notify;
use self::notify::{watcher, DebouncedEvent, RecursiveMode, Watcher}; use self::notify::{watcher, DebouncedEvent, RecursiveMode, Watcher};
@ -494,7 +494,7 @@ impl MboxFormat {
debug!("Could not parse mail {:?}", err); debug!("Could not parse mail {:?}", err);
Err(nom::Err::Error(NomError { Err(nom::Err::Error(NomError {
input, input,
code: ErrorKind::Tag, code: NomErrorKind::Tag,
})) }))
} }
} }
@ -541,7 +541,7 @@ impl MboxFormat {
debug!("Could not parse mail at {:?}", err); debug!("Could not parse mail at {:?}", err);
Err(nom::Err::Error(NomError { Err(nom::Err::Error(NomError {
input, input,
code: ErrorKind::Tag, code: NomErrorKind::Tag,
})) }))
} }
} }
@ -598,7 +598,7 @@ impl MboxFormat {
debug!("Could not parse mail {:?}", err); debug!("Could not parse mail {:?}", err);
Err(nom::Err::Error(NomError { Err(nom::Err::Error(NomError {
input, input,
code: ErrorKind::Tag, code: NomErrorKind::Tag,
})) }))
} }
} }
@ -645,7 +645,7 @@ impl MboxFormat {
debug!("Could not parse mail {:?}", err); debug!("Could not parse mail {:?}", err);
Err(nom::Err::Error(NomError { Err(nom::Err::Error(NomError {
input, input,
code: ErrorKind::Tag, code: NomErrorKind::Tag,
})) }))
} }
} }
@ -739,7 +739,7 @@ pub fn mbox_parse(
if input.is_empty() { if input.is_empty() {
return Err(nom::Err::Error(NomError { return Err(nom::Err::Error(NomError {
input, input,
code: ErrorKind::Tag, code: NomErrorKind::Tag,
})); }));
} }
let mut offset = 0; let mut offset = 0;
@ -963,7 +963,9 @@ impl MailBackend for MboxType {
} }
fn refresh(&mut self, _mailbox_hash: MailboxHash) -> ResultFuture<()> { 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<()> { fn watch(&self) -> ResultFuture<()> {
@ -1154,7 +1156,9 @@ impl MailBackend for MboxType {
_destination_mailbox_hash: MailboxHash, _destination_mailbox_hash: MailboxHash,
_move_: bool, _move_: bool,
) -> ResultFuture<()> { ) -> 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( fn set_flags(
@ -1163,7 +1167,9 @@ impl MailBackend for MboxType {
_mailbox_hash: MailboxHash, _mailbox_hash: MailboxHash,
_flags: SmallVec<[(std::result::Result<Flag, String>, bool); 8]>, _flags: SmallVec<[(std::result::Result<Flag, String>, bool); 8]>,
) -> ResultFuture<()> { ) -> 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( fn delete_messages(
@ -1171,7 +1177,9 @@ impl MailBackend for MboxType {
_env_hashes: EnvelopeHashBatch, _env_hashes: EnvelopeHashBatch,
_mailbox_hash: MailboxHash, _mailbox_hash: MailboxHash,
) -> ResultFuture<()> { ) -> 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( fn save(
@ -1180,7 +1188,9 @@ impl MailBackend for MboxType {
_mailbox_hash: MailboxHash, _mailbox_hash: MailboxHash,
_flags: Option<Flag>, _flags: Option<Flag>,
) -> ResultFuture<()> { ) -> 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 { fn as_any(&self) -> &dyn Any {
@ -1194,6 +1204,66 @@ impl MailBackend for MboxType {
fn collection(&self) -> Collection { fn collection(&self) -> Collection {
self.collection.clone() 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 { macro_rules! get_conf_val {

View File

@ -367,7 +367,10 @@ impl MailBackend for NntpType {
} }
fn watch(&self) -> ResultFuture<()> { 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>> { fn operation(&self, env_hash: EnvelopeHash) -> Result<Box<dyn BackendOp>> {
@ -440,14 +443,18 @@ impl MailBackend for NntpType {
&mut self, &mut self,
_path: String, _path: String,
) -> ResultFuture<(MailboxHash, HashMap<MailboxHash, Mailbox>)> { ) -> 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( fn delete_mailbox(
&mut self, &mut self,
_mailbox_hash: MailboxHash, _mailbox_hash: MailboxHash,
) -> ResultFuture<HashMap<MailboxHash, Mailbox>> { ) -> 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( fn set_mailbox_subscription(
@ -455,7 +462,9 @@ impl MailBackend for NntpType {
_mailbox_hash: MailboxHash, _mailbox_hash: MailboxHash,
_new_val: bool, _new_val: bool,
) -> ResultFuture<()> { ) -> 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( fn rename_mailbox(
@ -463,7 +472,9 @@ impl MailBackend for NntpType {
_mailbox_hash: MailboxHash, _mailbox_hash: MailboxHash,
_new_path: String, _new_path: String,
) -> ResultFuture<Mailbox> { ) -> 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( fn set_mailbox_permissions(
@ -471,7 +482,9 @@ impl MailBackend for NntpType {
_mailbox_hash: MailboxHash, _mailbox_hash: MailboxHash,
_val: crate::backends::MailboxPermissions, _val: crate::backends::MailboxPermissions,
) -> ResultFuture<()> { ) -> 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( fn search(
@ -479,7 +492,9 @@ impl MailBackend for NntpType {
_query: crate::search::Query, _query: crate::search::Query,
_mailbox_hash: Option<MailboxHash>, _mailbox_hash: Option<MailboxHash>,
) -> ResultFuture<SmallVec<[EnvelopeHash; 512]>> { ) -> 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( fn submit(

View File

@ -754,7 +754,9 @@ impl MailBackend for NotmuchDb {
_destination_mailbox_hash: MailboxHash, _destination_mailbox_hash: MailboxHash,
_move_: bool, _move_: bool,
) -> ResultFuture<()> { ) -> 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( fn set_flags(
@ -874,7 +876,9 @@ impl MailBackend for NotmuchDb {
_env_hashes: EnvelopeHashBatch, _env_hashes: EnvelopeHashBatch,
_mailbox_hash: MailboxHash, _mailbox_hash: MailboxHash,
) -> ResultFuture<()> { ) -> 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( fn search(
@ -925,6 +929,55 @@ impl MailBackend for NotmuchDb {
fn as_any_mut(&mut self) -> &mut dyn Any { fn as_any_mut(&mut self) -> &mut dyn Any {
self 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)] #[derive(Debug)]

View File

@ -172,7 +172,7 @@ mod strings {
named_unit_variant!(ask); named_unit_variant!(ask);
} }
#[derive(Copy, Debug, Clone, PartialEq)] #[derive(Copy, Debug, Clone, PartialEq, Eq)]
pub enum ToggleFlag { pub enum ToggleFlag {
Unset, Unset,
InternalVal(bool), InternalVal(bool),

View File

@ -25,7 +25,7 @@ use super::Envelope;
use smallvec::SmallVec; use smallvec::SmallVec;
use std::convert::From; use std::convert::From;
#[derive(Debug, PartialEq, Clone, Copy)] #[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum ListAction<'a> { pub enum ListAction<'a> {
Url(&'a [u8]), Url(&'a [u8]),
Email(&'a [u8]), Email(&'a [u8]),

View File

@ -34,7 +34,7 @@ use std::sync::Arc;
pub type Result<T> = result::Result<T, MeliError>; pub type Result<T> = result::Result<T, MeliError>;
#[derive(Debug, Copy, PartialEq, Clone)] #[derive(Debug, Copy, PartialEq, Eq, Clone)]
pub enum NetworkErrorKind { pub enum NetworkErrorKind {
/// Unspecified /// Unspecified
None, 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 { pub enum ErrorKind {
None, None,
External, External,

View File

@ -24,6 +24,8 @@
#![allow(non_snake_case)] #![allow(non_snake_case)]
#![allow(unused)] #![allow(unused)]
#![allow(dead_code)] #![allow(dead_code)]
#![allow(clippy::useless_transmute)]
#![allow(clippy::too_many_arguments)]
use libc::{off_t, time_t, FILE}; use libc::{off_t, time_t, FILE};
/* automatically generated by rust-bindgen */ /* automatically generated by rust-bindgen */

View File

@ -64,7 +64,7 @@ mod bindings;
use bindings::*; use bindings::*;
mod io; mod io;
#[derive(Debug, Clone, Copy, PartialEq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum GpgmeFlag { pub enum GpgmeFlag {
///"auto-key-retrieve" ///"auto-key-retrieve"
AutoKeyRetrieve, 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 { fn eq(&self, other: &Key) -> bool {
self.fingerprint() == other.fingerprint() self.fingerprint() == other.fingerprint()
} }
} }
impl Eq for Key {}
impl Drop for Key { impl Drop for Key {
#[inline] #[inline]
fn drop(&mut self) { fn drop(&mut self) {

View File

@ -240,7 +240,7 @@ pub mod shellexpand {
.components() .components()
.last() .last()
.map(|c| c.as_os_str()) .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() { let prefix = if let Some(p) = self.parent() {
p p
} else { } else {

View File

@ -88,7 +88,7 @@ use std::net::TcpStream;
use std::process::Command; use std::process::Command;
/// Kind of server security (StartTLS/TLS/None) the client should attempt /// 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")] #[serde(tag = "type")]
pub enum SmtpSecurity { pub enum SmtpSecurity {
#[serde(alias = "starttls", alias = "STARTTLS")] #[serde(alias = "starttls", alias = "STARTTLS")]
@ -119,7 +119,7 @@ impl Default for SmtpSecurity {
} }
/// Source of user's password for SMTP authentication /// 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")] #[serde(tag = "type", content = "value")]
pub enum Password { pub enum Password {
#[serde(alias = "raw")] #[serde(alias = "raw")]
@ -129,7 +129,7 @@ pub enum Password {
} }
/// Kind of server authentication the client should attempt /// Kind of server authentication the client should attempt
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] #[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
#[serde(tag = "type")] #[serde(tag = "type")]
pub enum SmtpAuth { pub enum SmtpAuth {
#[serde(alias = "none")] #[serde(alias = "none")]
@ -152,7 +152,7 @@ pub enum SmtpAuth {
// md5, sasl, etc // md5, sasl, etc
} }
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Default)] #[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize, Default)]
pub struct SmtpAuthType { pub struct SmtpAuthType {
plain: bool, plain: bool,
login: bool, login: bool,
@ -761,7 +761,7 @@ impl SmtpConnection {
pub type ExpectedReplyCode = Option<(ReplyCode, &'static [ReplyCode])>; pub type ExpectedReplyCode = Option<(ReplyCode, &'static [ReplyCode])>;
/// Recognized kinds of SMTP reply codes /// Recognized kinds of SMTP reply codes
#[derive(Debug, Copy, Clone, PartialEq)] #[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum ReplyCode { pub enum ReplyCode {
///System status, or system help reply ///System status, or system help reply
_211, _211,

View File

@ -20,7 +20,7 @@
*/ */
#[allow(clippy::upper_case_acronyms)] #[allow(clippy::upper_case_acronyms)]
#[derive(Debug, Copy, Clone, PartialEq)] #[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum LineBreakClass { pub enum LineBreakClass {
BK, BK,
CM, CM,
@ -123,7 +123,7 @@ impl From<&str> for LineBreakClass {
} }
} }
#[derive(PartialEq, Debug, Copy, Clone)] #[derive(PartialEq, Eq, Debug, Copy, Clone)]
pub enum Reflow { pub enum Reflow {
No, No,
All, All,

View File

@ -452,13 +452,13 @@ impl SubjectPrefix for &str {
/* Sorting states. */ /* Sorting states. */
#[derive(Debug, Clone, PartialEq, Copy, Deserialize, Serialize)] #[derive(Debug, Clone, PartialEq, Eq, Copy, Deserialize, Serialize)]
pub enum SortOrder { pub enum SortOrder {
Asc, Asc,
Desc, Desc,
} }
#[derive(Debug, Clone, PartialEq, Copy, Deserialize, Serialize)] #[derive(Debug, Clone, PartialEq, Eq, Copy, Deserialize, Serialize)]
pub enum SortField { pub enum SortField {
Subject, Subject,
Date, Date,
@ -550,6 +550,10 @@ impl Thread {
self.attachments > 0 self.attachments > 0
} }
pub fn is_empty(&self) -> bool {
self.len == 0
}
pub fn set_snoozed(&mut self, val: bool) { pub fn set_snoozed(&mut self, val: bool) {
self.snoozed = val; self.snoozed = val;
} }
@ -654,6 +658,8 @@ impl PartialEq for ThreadNode {
} }
} }
impl Eq for ThreadNode {}
impl Threads { impl Threads {
pub fn is_snoozed(&self, h: ThreadNodeHash) -> bool { pub fn is_snoozed(&self, h: ThreadNodeHash) -> bool {
self.thread_ref(self.thread_nodes[&h].group).snoozed() self.thread_ref(self.thread_nodes[&h].group).snoozed()
@ -1442,6 +1448,10 @@ impl Threads {
self.hash_set.len() self.hash_set.len()
} }
pub fn is_empty(&self) -> bool {
self.hash_set.is_empty()
}
pub fn root_len(&self) -> usize { pub fn root_len(&self) -> usize {
self.tree_index.read().unwrap().len() self.tree_index.read().unwrap().len()
} }