forked from meli/meli
1
Fork 0

rustfmt changes

sieve
Manos Pitsidianakis 2022-12-27 18:40:26 +02:00
parent 5443b7e8f3
commit de2f46fe61
13 changed files with 40 additions and 76 deletions

View File

@ -40,7 +40,7 @@ pub use self::imap::ImapType;
#[cfg(feature = "imap_backend")]
pub use self::nntp::NntpType;
use crate::conf::AccountSettings;
use crate::error::{ErrorKind, Error, Result};
use crate::error::{Error, ErrorKind, Result};
#[cfg(feature = "maildir_backend")]
use self::maildir::MaildirType;

View File

@ -1245,9 +1245,7 @@ impl MailBackend for ImapType {
));
}
}
Err(Error::new(
String::from_utf8_lossy(&response).to_string(),
))
Err(Error::new(String::from_utf8_lossy(&response).to_string()))
}))
}
}

View File

@ -240,10 +240,7 @@ impl ImapStream {
let addr = if let Ok(a) = lookup_ipv4(path, server_conf.server_port) {
a
} else {
return Err(Error::new(format!(
"Could not lookup address {}",
&path
)));
return Err(Error::new(format!("Could not lookup address {}", &path)));
};
AsyncWrapper::new(Connection::Tcp(
if let Some(timeout) = server_conf.timeout {

View File

@ -82,11 +82,10 @@ impl BackendOp for ImapOp {
);
let mut results = protocol_parser::fetch_responses(&response)?.1;
if results.len() != 1 {
return Err(Error::new(format!(
"Invalid/unexpected response: {:?}",
response
))
.set_summary(format!("message with UID {} was not found?", uid)));
return Err(
Error::new(format!("Invalid/unexpected response: {:?}", response))
.set_summary(format!("message with UID {} was not found?", uid)),
);
}
let FetchResponse {
uid: _uid,
@ -147,11 +146,10 @@ impl BackendOp for ImapOp {
debug!(String::from_utf8_lossy(&response));
/* TODO: Trigger cache invalidation here. */
debug!("message with UID {} was not found", uid);
return Err(Error::new(format!(
"Invalid/unexpected response: {:?}",
response
))
.set_summary(format!("message with UID {} was not found?", uid)));
return Err(
Error::new(format!("Invalid/unexpected response: {:?}", response))
.set_summary(format!("message with UID {} was not found?", uid)),
);
}
let (_uid, (_flags, _)) = v[0];
assert_eq!(_uid, uid);

View File

@ -28,7 +28,7 @@ use super::{MaildirMailbox, MaildirOp, MaildirPathTrait};
use crate::backends::{RefreshEventKind::*, *};
use crate::conf::AccountSettings;
use crate::email::{Envelope, EnvelopeHash, Flag};
use crate::error::{ErrorKind, Error, Result};
use crate::error::{Error, ErrorKind, Result};
use crate::shellexpand::ShellExpandTrait;
use crate::Collection;
use futures::prelude::Stream;

View File

@ -126,7 +126,7 @@ use crate::collection::Collection;
use crate::conf::AccountSettings;
use crate::email::parser::BytesExt;
use crate::email::*;
use crate::error::{ErrorKind, Error, Result};
use crate::error::{Error, ErrorKind, Result};
use crate::get_path_hash;
use crate::shellexpand::ShellExpandTrait;
use nom::bytes::complete::tag;
@ -1244,10 +1244,8 @@ impl MailBackend for MboxType {
_query: crate::search::Query,
_mailbox_hash: Option<MailboxHash>,
) -> ResultFuture<SmallVec<[EnvelopeHash; 512]>> {
Err(
Error::new("Search is unimplemented for the mbox backend.")
.set_kind(ErrorKind::NotImplemented),
)
Err(Error::new("Search is unimplemented for the mbox backend.")
.set_kind(ErrorKind::NotImplemented))
}
fn create_mailbox(

View File

@ -270,10 +270,9 @@ pub fn lookup_ipv4(host: &str, port: u16) -> crate::Result<std::net::SocketAddr>
}
Err(
crate::error::Error::new(format!("Could not lookup address {}:{}", host, port))
.set_kind(crate::error::ErrorKind::Network(
crate::error::NetworkErrorKind::HostLookupFailed,
)),
crate::error::Error::new(format!("Could not lookup address {}:{}", host, port)).set_kind(
crate::error::ErrorKind::Network(crate::error::NetworkErrorKind::HostLookupFailed),
),
)
}
@ -284,8 +283,10 @@ pub async fn timeout<O>(dur: Option<Duration>, f: impl Future<Output = O>) -> cr
if let Some(dur) = dur {
match future::select(f, smol::Timer::after(dur)).await {
Either::Left((out, _)) => Ok(out),
Either::Right(_) => Err(crate::error::Error::new("Timed out.")
.set_kind(crate::error::ErrorKind::Timeout)),
Either::Right(_) => {
Err(crate::error::Error::new("Timed out.")
.set_kind(crate::error::ErrorKind::Timeout))
}
}
} else {
Ok(f.await)

View File

@ -23,7 +23,7 @@ use crate::email::{
pgp::{DecryptionMetadata, Recipient},
Address,
};
use crate::error::{ErrorKind, IntoError, Error, Result, ResultIntoError};
use crate::error::{Error, ErrorKind, IntoError, Result, ResultIntoError};
use futures::FutureExt;
use serde::{
de::{self, Deserialize},
@ -259,9 +259,8 @@ impl Context {
}
let ret = Context {
inner: Arc::new(ContextInner {
inner: core::ptr::NonNull::new(ptr).ok_or_else(|| {
Error::new("Could not use libgpgme").set_kind(ErrorKind::Bug)
})?,
inner: core::ptr::NonNull::new(ptr)
.ok_or_else(|| Error::new("Could not use libgpgme").set_kind(ErrorKind::Bug))?,
lib,
}),
io_state,
@ -714,9 +713,8 @@ impl Context {
let mut sig = Data {
lib: self.inner.lib.clone(),
kind: DataKind::Memory,
inner: core::ptr::NonNull::new(sig).ok_or_else(|| {
Error::new("internal libgpgme error").set_kind(ErrorKind::Bug)
})?,
inner: core::ptr::NonNull::new(sig)
.ok_or_else(|| Error::new("internal libgpgme error").set_kind(ErrorKind::Bug))?,
};
let io_state = self.io_state.clone();
@ -818,9 +816,8 @@ impl Context {
let mut plain = Data {
lib: self.inner.lib.clone(),
kind: DataKind::Memory,
inner: core::ptr::NonNull::new(plain).ok_or_else(|| {
Error::new("internal libgpgme error").set_kind(ErrorKind::Bug)
})?,
inner: core::ptr::NonNull::new(plain)
.ok_or_else(|| Error::new("internal libgpgme error").set_kind(ErrorKind::Bug))?,
};
let ctx = self.inner.clone();
@ -1030,9 +1027,8 @@ impl Context {
let mut cipher = Data {
lib: self.inner.lib.clone(),
kind: DataKind::Memory,
inner: core::ptr::NonNull::new(cipher).ok_or_else(|| {
Error::new("internal libgpgme error").set_kind(ErrorKind::Bug)
})?,
inner: core::ptr::NonNull::new(cipher)
.ok_or_else(|| Error::new("internal libgpgme error").set_kind(ErrorKind::Bug))?,
};
let ctx = self.inner.clone();

View File

@ -148,10 +148,7 @@ impl Component for KeySelection {
}
} else {
*self = KeySelection::Error {
err: Error::new(format!(
"No keys found for {}.",
pattern
)),
err: Error::new(format!("No keys found for {}.", pattern)),
id,
}
}

View File

@ -401,11 +401,7 @@ This is required so that you don't accidentally start meli and find out later th
let mut file = OpenOptions::new().append(true).open(&path)?;
file.write_all("[composing]\nsend_mail = 'false'\n".as_bytes())
.map_err(|err| {
Error::new(format!(
"Could not append to {}: {}",
path.display(),
err
))
Error::new(format!("Could not append to {}: {}", path.display(), err))
})?;
return FileSettings::validate(path, interactive, clear_extras);
}

View File

@ -28,7 +28,7 @@ use crate::jobs::{JobExecutor, JobId, JoinHandle};
use indexmap::IndexMap;
use melib::backends::*;
use melib::email::*;
use melib::error::{ErrorKind, Error, Result};
use melib::error::{Error, ErrorKind, Result};
use melib::text_processing::GlobMatch;
use melib::thread::{SortField, SortOrder, Threads};
use melib::AddressBook;
@ -1394,9 +1394,7 @@ impl Account {
)
};
melib::log(&error_message, melib::LoggingLevel::ERROR);
return Err(
Error::new(error_message).set_summary("Message not sent.")
);
return Err(Error::new(error_message).set_summary("Message not sent."));
}
Ok(())
}

View File

@ -1212,23 +1212,14 @@ impl Themes {
Themes::validate_keys(name, t, &hash_set)?;
}
if let Err(err) = is_cyclic(&self.light) {
return Err(Error::new(format!(
"light theme contains a cycle: {}",
err
)));
return Err(Error::new(format!("light theme contains a cycle: {}", err)));
}
if let Err(err) = is_cyclic(&self.dark) {
return Err(Error::new(format!(
"dark theme contains a cycle: {}",
err
)));
return Err(Error::new(format!("dark theme contains a cycle: {}", err)));
}
for (k, t) in self.other_themes.iter() {
if let Err(err) = is_cyclic(t) {
return Err(Error::new(format!(
"{} theme contains a cycle: {}",
k, err
)));
return Err(Error::new(format!("{} theme contains a cycle: {}", k, err)));
}
}
Ok(())

View File

@ -78,10 +78,7 @@ fn parse_manpage(src: &str) -> Result<ManPages> {
"meli.7" | "guide" => Ok(ManPages::Guide),
"meli.conf" | "meli.conf.5" | "conf" | "config" | "configuration" => Ok(ManPages::Conf),
"meli-themes" | "meli-themes.5" | "themes" | "theming" | "theme" => Ok(ManPages::Themes),
_ => Err(Error::new(format!(
"Invalid documentation page: {}",
src
))),
_ => Err(Error::new(format!("Invalid documentation page: {}", src))),
}
}
@ -284,10 +281,7 @@ fn run_app(opt: Opt) -> Result<()> {
path.display()
)));
} else if !path.is_file() {
return Err(Error::new(format!(
"`{}` is a directory",
path.display()
)));
return Err(Error::new(format!("`{}` is a directory", path.display())));
}
}
None => {}