aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDirk Van Haerenborgh <vhdirk@gmail.com>2019-11-16 21:01:54 +0100
committerDirk Van Haerenborgh <vhdirk@gmail.com>2019-11-16 21:01:54 +0100
commit3b92173d12659231629c2205138b0857b66942f3 (patch)
tree276cb15d1535f724eb3613de9b8b69ad457303ec
parente16769c9b16223c491766f9c9b2c828ee2253ed4 (diff)
downloadmail-3b92173d12659231629c2205138b0857b66942f3.tar.gz
make clippy happy
-rw-r--r--Cargo.toml2
-rw-r--r--src/config_list.rs6
-rw-r--r--src/error.rs2
-rw-r--r--src/index.rs7
-rw-r--r--src/message.rs4
-rw-r--r--src/message_properties.rs5
-rw-r--r--src/messages.rs2
-rw-r--r--src/utils.rs6
-rw-r--r--tests/commands.rs140
-rw-r--r--tests/fixtures.rs49
-rw-r--r--tests/test_database.rs5
-rw-r--r--tests/test_message.rs12
-rw-r--r--tests/test_tags.rs10
13 files changed, 29 insertions, 221 deletions
diff --git a/Cargo.toml b/Cargo.toml
index f51bda2..48e7415 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "notmuch"
-version = "0.5.0"
+version = "0.6.0"
authors = ["Dirk Van Haerenborgh <vhdirk@gmail.com>"]
homepage = "https://github.com/vhdirk/notmuch-rs"
repository = "https://github.com/vhdirk/notmuch-rs"
diff --git a/src/config_list.rs b/src/config_list.rs
index b819418..2c1a6a4 100644
--- a/src/config_list.rs
+++ b/src/config_list.rs
@@ -1,12 +1,8 @@
use std::ops::Drop;
-use std::ffi::{CStr, CString};
-use supercow::Supercow;
use ffi;
use Database;
-use Filenames;
-use FilenamesOwner;
-use utils::{ToStr, ScopedSupercow, ScopedPhantomcow};
+use utils::{ToStr, ScopedPhantomcow};
#[derive(Debug)]
diff --git a/src/error.rs b/src/error.rs
index 824cc39..64d0716 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -27,7 +27,7 @@ impl std::error::Error for Error {
}
}
- fn cause(&self) -> Option<&error::Error> {
+ fn cause(&self) -> Option<&dyn error::Error> {
match *self {
Error::IoError(ref e) => Some(e),
Error::NotmuchError(ref e) => Some(e),
diff --git a/src/index.rs b/src/index.rs
index f070020..4db6bc7 100644
--- a/src/index.rs
+++ b/src/index.rs
@@ -1,13 +1,10 @@
use std::ops::Drop;
-use supercow::{Supercow, Phantomcow};
-use error::{Error, Result};
+use error::Result;
use ffi;
use ffi::DecryptionPolicy;
use Database;
-use Filenames;
-use FilenamesOwner;
-use utils::{ScopedSupercow, ScopedPhantomcow};
+use utils::ScopedPhantomcow;
#[derive(Debug)]
diff --git a/src/message.rs b/src/message.rs
index 20ad957..55a544f 100644
--- a/src/message.rs
+++ b/src/message.rs
@@ -1,5 +1,5 @@
-use std::ffi::{CString, CStr};
-use std::path::{Path, PathBuf};
+use std::ffi::CString;
+use std::path::PathBuf;
use std::cell::RefCell;
use std::borrow::Cow;
use std::ptr;
diff --git a/src/message_properties.rs b/src/message_properties.rs
index 19ea960..bd20aa0 100644
--- a/src/message_properties.rs
+++ b/src/message_properties.rs
@@ -1,11 +1,10 @@
use std::ops::Drop;
-use std::ffi::{CStr, CString};
-use supercow::Supercow;
+use std::ffi::CStr;
use ffi;
use Message;
use MessageOwner;
-use utils::{ScopedSupercow, ScopedPhantomcow};
+use utils::{ScopedPhantomcow};
#[derive(Debug)]
diff --git a/src/messages.rs b/src/messages.rs
index 60a6f7d..48d30ef 100644
--- a/src/messages.rs
+++ b/src/messages.rs
@@ -1,5 +1,3 @@
-use std::ops::Drop;
-
use ffi;
use utils::ScopedPhantomcow;
use MessageOwner;
diff --git a/src/utils.rs b/src/utils.rs
index 6030f38..57e4004 100644
--- a/src/utils.rs
+++ b/src/utils.rs
@@ -4,6 +4,7 @@ use std::borrow::Cow;
use supercow::{Supercow, DefaultFeatures/*, NonSyncFeatures*/};
use supercow::ext::{BoxedStorage};
+
pub trait ToStr {
fn to_str<'a>(&self) -> Result<&'a str, str::Utf8Error>;
@@ -48,8 +49,3 @@ pub type ScopedPhantomcow<'a, OWNED, BORROWED = OWNED,
pub type ScopedSupercow<'a, OWNED, BORROWED = OWNED, SHARED = Box<dyn DefaultFeatures<'a> + 'a>> =
Supercow<'a, OWNED, BORROWED, SHARED, BoxedStorage>;
-
-
-
-
-
diff --git a/tests/commands.rs b/tests/commands.rs
deleted file mode 100644
index c9f9d60..0000000
--- a/tests/commands.rs
+++ /dev/null
@@ -1,140 +0,0 @@
-extern crate dirs;
-extern crate notmuch;
-extern crate supercow;
-
-use std::path::Path;
-use std::sync::Arc;
-use std::result::Result;
-use supercow::Supercow;
-use notmuch::ScopedSupercow;
-
-use notmuch::{
- Database,
- DatabaseExt,
- Query,
- QueryExt,
- Message,
- FrozenMessage,
- Error
-};
-
-#[derive(Debug)]
-pub struct AtomicOperation<'d> {
- database: ScopedSupercow<'d, Database>,
-}
-
-impl<'d> AtomicOperation<'d> {
- pub fn new<D>(db: D) -> Result<Self, Error>
- where
- D: Into<ScopedSupercow<'d, Database>>,
- {
- let database = db.into();
- database.begin_atomic()?;
- Ok(AtomicOperation{
- database
- })
- }
-}
-
-impl<'d> Drop for AtomicOperation<'d> {
- fn drop(&mut self) {
- let _ = self.database.end_atomic();
- }
-}
-
-/// Add a single file to the database
-pub fn add_file<'d, D, P>(db: D, filename: &P) -> Result<Message<'d, Database>, Error>
-where
- D: Into<ScopedSupercow<'d, Database>>,
- P: AsRef<Path>
-{
- let mut database = db.into();
-
- let _atomic = AtomicOperation::new(Supercow::share(&mut database)).unwrap();
-
- match <Database as DatabaseExt>::index_file(Supercow::share(&mut database), filename, None) {
- Ok(msg) => {
-
- // scoped version of freezing a message
- {
- let _fmsg = FrozenMessage::new(&msg);
-
-
- }
- Ok(msg)
- },
- Err(err) => {
- Err(err)
- }
- }
-
-
-}
-
-
-#[cfg(test)]
-mod tests {
- use super::*;
-
- #[test]
- fn test_add_file() {
-
-
-
- }
-}
-
-
-
-// status = notmuch_database_index_file (notmuch, filename, indexing_cli_choices.opts, &message);
-// switch (status) {
-// /* Success. */
-// case NOTMUCH_STATUS_SUCCESS:
-// state->added_messages++;
-// notmuch_message_freeze (message);
-// if (state->synchronize_flags)
-// notmuch_message_maildir_flags_to_tags (message);
-
-// for (tag = state->new_tags; *tag != NULL; tag++) {
-// if (strcmp ("unread", *tag) != 0 ||
-// ! notmuch_message_has_maildir_flag (message, 'S')) {
-// notmuch_message_add_tag (message, *tag);
-// }
-// }
-
-// notmuch_message_thaw (message);
-// break;
-// /* Non-fatal issues (go on to next file). */
-// case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID:
-// if (state->synchronize_flags)
-// notmuch_message_maildir_flags_to_tags (message);
-// break;
-// case NOTMUCH_STATUS_FILE_NOT_EMAIL:
-// fprintf (stderr, "Note: Ignoring non-mail file: %s\n", filename);
-// break;
-// case NOTMUCH_STATUS_FILE_ERROR:
-// /* Someone renamed/removed the file between scandir and now. */
-// state->vanished_files++;
-// fprintf (stderr, "Unexpected error with file %s\n", filename);
-// (void) print_status_database ("add_file", notmuch, status);
-// break;
-// /* Fatal issues. Don't process anymore. */
-// case NOTMUCH_STATUS_READ_ONLY_DATABASE:
-// case NOTMUCH_STATUS_XAPIAN_EXCEPTION:
-// case NOTMUCH_STATUS_OUT_OF_MEMORY:
-// (void) print_status_database ("add_file", notmuch, status);
-// goto DONE;
-// default:
-// INTERNAL_ERROR ("add_message returned unexpected value: %d", status);
-// goto DONE;
-// }
-
-// status = notmuch_database_end_atomic (notmuch);
-
-// DONE:
-// if (message)
-// notmuch_message_destroy (message);
-
-// return status;
-// }
- \ No newline at end of file
diff --git a/tests/fixtures.rs b/tests/fixtures.rs
index a8166be..7075905 100644
--- a/tests/fixtures.rs
+++ b/tests/fixtures.rs
@@ -7,25 +7,16 @@ extern crate lettre;
extern crate lettre_email;
use std::ffi::OsStr;
-use std::io::{self, Result, Write};
+use std::io::{Result, Write};
use std::fs::{self, File};
-use std::rc::Rc;
-use std::path::{Path, PathBuf};
-use tempfile::{tempdir, tempdir_in, Builder, TempDir};
-use std::net::ToSocketAddrs;
+use std::path::PathBuf;
+use tempfile::{tempdir, TempDir};
use std::process::Command;
-use std::time::{SystemTime, UNIX_EPOCH};
use maildir::Maildir;
use lettre_email::{EmailBuilder, Header};
use lettre::SendableEmail;
-pub fn timestamp_ms() -> u128 {
- let start = SystemTime::now();
- let time_since_epoch = start.duration_since(UNIX_EPOCH).unwrap();
- time_since_epoch.as_millis()
-}
-
// A basic test interface to a valid maildir directory.
//
// This creates a valid maildir and provides a simple mechanism to
@@ -33,7 +24,6 @@ pub fn timestamp_ms() -> u128 {
// in the top of the maildir.
pub struct MailBox {
root_dir: TempDir,
- idcount: u32,
maildir: Maildir
}
@@ -73,7 +63,6 @@ impl MailBox {
Self {
root_dir,
- idcount: 0,
maildir
}
}
@@ -86,16 +75,10 @@ impl MailBox {
// msgid
// }
- pub fn path(&self) -> PathBuf
- {
+ pub fn path(&self) -> PathBuf {
self.root_dir.path().into()
}
- pub fn hostname(&self) -> String {
- let hname = gethostname::gethostname();
- hname.to_string_lossy().into()
- }
-
/// Deliver a new mail message in the mbox.
/// This does only adds the message to maildir, does not insert it
/// into the notmuch database.
@@ -107,7 +90,7 @@ impl MailBox {
from: Option<String>,
headers: Vec<(String, String)>,
is_new: bool, // Move to new dir or cur dir?
- keywords: Option<Vec<String>>, // List of keywords or labels
+ _keywords: Option<Vec<String>>, // List of keywords or labels
seen: bool, // Seen flag (cur dir only)
replied: bool, // Replied flag (cur dir only)
flagged: bool) // Flagged flag (cur dir only)
@@ -154,27 +137,7 @@ impl MailBox {
format!("{}:2,{}", mid, flags)
};
- // let mut flags = String::from("");
- // if flagged {
- // flags += "F";
- // }
- // if replied {
- // flags += "R";
- // }
- // if seen {
- // flags += "S";
- // }
- // println!("flags: {:?}", flags);
- // let id = self.maildir.store_cur_with_flags(&msg.message_to_string().unwrap().as_bytes(), flags.as_str()).unwrap();
-
- // if is_new {
- // let msgpath = format!("{}{}", id, flags);
- // std::fs::rename(msgpath, newpath)?;
-
- // self.maildir.path()
- // }
-
-
+
let mut msgpath = self.path();
msgpath = if is_new {
msgpath.join("new")
diff --git a/tests/test_database.rs b/tests/test_database.rs
index 557e0c3..098e271 100644
--- a/tests/test_database.rs
+++ b/tests/test_database.rs
@@ -85,7 +85,7 @@ mod database {
mod atomic {
- use super::*;
+ // use super::*;
// TODO: how do I test this??
@@ -107,6 +107,7 @@ mod revision {
assert!(rev0 == rev1);
assert!(rev0 <= rev1);
assert!(rev0 >= rev1);
+
assert!(!(rev0 < rev1));
assert!(!(rev0 > rev1));
}
@@ -176,7 +177,7 @@ mod messages {
let db = notmuch::Database::create(&mailbox.path()).unwrap();
let (msgid, filename) = mailbox.deliver(None, None, None, None, vec![], true, None, false, false, false).unwrap();
- let msg = db.index_file(&filename, None).unwrap();
+ db.index_file(&filename, None).unwrap();
assert!(db.find_message(&msgid).unwrap().is_some());
db.remove_message(&filename).unwrap();
diff --git a/tests/test_message.rs b/tests/test_message.rs
index 7a6391d..7af6f2c 100644
--- a/tests/test_message.rs
+++ b/tests/test_message.rs
@@ -249,11 +249,11 @@ mod properties {
let msg = MessageFixture::new();
msg.message.add_property(&"foo", &"a").unwrap();
- let mut prop_keys: Vec<String> = msg.message.properties(&"foo", false).map(|x| x.0).collect();
+ let prop_keys: Vec<String> = msg.message.properties(&"foo", false).map(|x| x.0).collect();
assert_eq!(prop_keys.len(), 1);
assert_eq!(prop_keys, vec!["foo"]);
- let mut prop_vals: Vec<String> = msg.message.properties(&"foo", false).map(|x| x.1).collect();
+ let prop_vals: Vec<String> = msg.message.properties(&"foo", false).map(|x| x.1).collect();
assert_eq!(prop_vals.len(), 1);
assert_eq!(prop_vals, vec!["a"]);
}
@@ -264,11 +264,11 @@ mod properties {
msg.message.add_property(&"foo", &"a").unwrap();
msg.message.add_property(&"foobar", &"b").unwrap();
- let mut prop_keys: Vec<String> = msg.message.properties(&"foo", false).map(|x| x.0).collect();
+ let prop_keys: Vec<String> = msg.message.properties(&"foo", false).map(|x| x.0).collect();
assert_eq!(prop_keys.len(), 2);
assert_eq!(prop_keys, vec!["foo", "foobar"]);
- let mut prop_vals: Vec<String> = msg.message.properties(&"foo", false).map(|x| x.1).collect();
+ let prop_vals: Vec<String> = msg.message.properties(&"foo", false).map(|x| x.1).collect();
assert_eq!(prop_vals.len(), 2);
assert_eq!(prop_vals, vec!["a", "b"]);
}
@@ -279,11 +279,11 @@ mod properties {
msg.message.add_property(&"foo", &"a").unwrap();
msg.message.add_property(&"foobar", &"b").unwrap();
- let mut prop_keys: Vec<String> = msg.message.properties(&"foo", true).map(|x| x.0).collect();
+ let prop_keys: Vec<String> = msg.message.properties(&"foo", true).map(|x| x.0).collect();
assert_eq!(prop_keys.len(), 1);
assert_eq!(prop_keys, vec!["foo"]);
- let mut prop_vals: Vec<String> = msg.message.properties(&"foo", true).map(|x| x.1).collect();
+ let prop_vals: Vec<String> = msg.message.properties(&"foo", true).map(|x| x.1).collect();
assert_eq!(prop_vals.len(), 1);
assert_eq!(prop_vals, vec!["a"]);
}
diff --git a/tests/test_tags.rs b/tests/test_tags.rs
index 5ddabeb..3d39486 100644
--- a/tests/test_tags.rs
+++ b/tests/test_tags.rs
@@ -1,5 +1,4 @@
use std::sync::Arc;
-use std::path::PathBuf;
use fixtures::{MailBox, NotmuchCommand};
struct TagSetFixture {
@@ -109,7 +108,6 @@ mod mutable {
fn test_from_maildir_flags(){
let tagset = TagSetFixture::new(true, true);
- let msgid = tagset.message.id();
tagset.message.remove_tag(&"flagged").unwrap();
tagset.message.maildir_flags_to_tags().unwrap();
@@ -125,20 +123,20 @@ mod mutable {
let filename = tagset.message.filename();
let filestr = filename.to_string_lossy();
- let file_parts: Vec<&str> = filestr.split(",").collect();
+ let file_parts: Vec<&str> = filestr.split(',').collect();
let flags = file_parts.last().unwrap();
println!("Flags {:?}", flags);
- assert!(flags.contains("F"));
+ assert!(flags.contains('F'));
tagset.message.remove_tag(&"flagged").unwrap();
tagset.message.tags_to_maildir_flags().unwrap();
let filename = tagset.message.filename();
let filestr = filename.to_string_lossy();
- let file_parts: Vec<&str> = filestr.split(",").collect();
+ let file_parts: Vec<&str> = filestr.split(',').collect();
let flags = file_parts.last().unwrap();
- assert!(!flags.contains("F"));
+ assert!(!flags.contains('F'));
}
} \ No newline at end of file