Browse Source

update to 2018 edition

embed
Manos Pitsidianakis 4 years ago
parent
commit
1c7aa0ec9c
Signed by: epilys GPG Key ID: 73627C2F690DF710
  1. 1
      Cargo.toml
  2. 105
      benches/maildir.rs
  3. 18
      benches/parse.rs
  4. 1
      melib/Cargo.toml
  5. 0
      melib/src/async_workers.rs
  6. 2
      melib/src/lib.rs
  7. 6
      melib/src/mailbox.rs
  8. 17
      melib/src/mailbox/backends.rs
  9. 10
      melib/src/mailbox/backends/maildir.rs
  10. 20
      melib/src/mailbox/backends/maildir/backend.rs
  11. 6
      melib/src/mailbox/collection.rs
  12. 6
      melib/src/mailbox/email.rs
  13. 4
      melib/src/mailbox/email/attachment_types.rs
  14. 8
      melib/src/mailbox/email/attachments.rs
  15. 6
      melib/src/mailbox/email/compose.rs
  16. 7
      melib/src/mailbox/thread.rs
  17. 8
      src/bin.rs
  18. 8
      ui/src/conf/accounts.rs
  19. 2
      ui/src/workers.rs

1
Cargo.toml

@ -2,6 +2,7 @@
name = "meli"
version = "0.1.0"
authors = ["Manos Pitsidianakis <el13635@mail.ntua.gr>"]
edition = "2018"
[[bin]]
name = "meli"

105
benches/maildir.rs

@ -1,43 +1,62 @@
#![feature(test)]
extern crate melib;
use melib::conf::Folder;
use melib::mailbox::backends::maildir::*;
extern crate test;
use self::test::Bencher;
#[bench]
fn bench_threads_1(b: &mut Bencher) {
b.iter(|| {
let folder = Folder::new(String::from(""), String::from(""), vec![]);
MaildirType::new("").multicore(1, &folder)
});
}
#[bench]
fn bench_threads_2(b: &mut Bencher) {
b.iter(|| {
let folder = Folder::new(String::from(""), String::from(""), vec![]);
MaildirType::new("").multicore(2, &folder)
});
}
#[bench]
fn bench_threads_3(b: &mut Bencher) {
b.iter(|| {
let folder = Folder::new(String::from(""), String::from(""), vec![]);
MaildirType::new("").multicore(3, &folder)
});
}
#[bench]
fn bench_threads_4(b: &mut Bencher) {
b.iter(|| {
let folder = Folder::new(String::from(""), String::from(""), vec![]);
MaildirType::new("").multicore(4, &folder)
});
}
#[bench]
fn bench_threads_6(b: &mut Bencher) {
b.iter(|| {
let folder = Folder::new(String::from(""), String::from(""), vec![]);
MaildirType::new("").multicore(6, &folder)
});
}
//#![feature(test)]
//use melib::conf::AccountSettings;
//use melib::mailbox::backends::maildir::*;
//
//extern crate test;
//use self::test::Bencher;
//
//#[bench]
//fn bench_threads_1(b: &mut Bencher) {
// b.iter(|| {
// let folder = Folder::new(
// String::from(""),
// String::from(""),
// vec![],
// );
// MaildirType::new("").multicore(1, &folder)
// });
//}
//#[bench]
//fn bench_threads_2(b: &mut Bencher) {
// b.iter(|| {
// let folder = Folder::new(
// String::from(""),
// String::from(""),
// vec![],
// );
// MaildirType::new("").multicore(2, &folder)
// });
//}
//#[bench]
//fn bench_threads_3(b: &mut Bencher) {
// b.iter(|| {
// let folder = Folder::new(
// String::from(""),
// String::from(""),
// vec![],
// );
// MaildirType::new("").multicore(3, &folder)
// });
//}
//#[bench]
//fn bench_threads_4(b: &mut Bencher) {
// b.iter(|| {
// let folder = Folder::new(
// String::from(""),
// String::from(""),
// vec![],
// );
// MaildirType::new("").multicore(4, &folder)
// });
//}
//#[bench]
//fn bench_threads_6(b: &mut Bencher) {
// b.iter(|| {
// let folder = Folder::new(
// String::from(""),
// String::from(""),
// vec![],
// );
// MaildirType::new("").multicore(6, &folder)
// });
//}

18
benches/parse.rs

@ -1,12 +1,12 @@
#![feature(test)]
extern crate melib;
use melib::mailbox::backends::maildir::MaildirOp;
use melib::mailbox::backends::BackendOpGenerator;
use melib::mailbox::email::Envelope;
extern crate test;
use self::test::Bencher;
//#![feature(test)]
//extern crate melib;
//
//use melib::mailbox::backends::maildir::MaildirOp;
//use melib::mailbox::backends::BackendOpGenerator;
//use melib::mailbox::email::Envelope;
//
//extern crate test;
//use self::test::Bencher;
/*
#[bench]

1
melib/Cargo.toml

@ -1,6 +1,7 @@
[package]
name = "melib"
version = "0.0.1" #:version
edition = "2018"
authors = []
workspace = ".."

0
melib/src/async.rs → melib/src/async_workers.rs

2
melib/src/lib.rs

@ -19,7 +19,7 @@
* along with meli. If not, see <http://www.gnu.org/licenses/>.
*/
pub mod addressbook;
pub mod async;
pub mod async_workers;
pub mod conf;
pub mod error;
pub mod mailbox;

6
melib/src/mailbox.rs

@ -29,10 +29,10 @@ pub mod email;
pub use self::email::*;
/* Mail backends. Currently only maildir is supported */
pub mod backends;
use error::Result;
use mailbox::backends::Folder;
use crate::error::Result;
use self::backends::Folder;
pub mod thread;
pub use mailbox::thread::{SortField, SortOrder, ThreadNode, Threads};
pub use self::thread::{SortField, SortOrder, ThreadNode, Threads};
mod collection;
pub use self::collection::*;

17
melib/src/mailbox/backends.rs

@ -22,19 +22,18 @@ pub mod imap;
pub mod maildir;
pub mod mbox;
use async::*;
use conf::AccountSettings;
use error::Result;
use crate::async_workers::*;
use crate::conf::AccountSettings;
use crate::error::Result;
//use mailbox::backends::imap::ImapType;
//use mailbox::backends::mbox::MboxType;
use mailbox::backends::maildir::MaildirType;
use mailbox::email::{Envelope, EnvelopeHash, Flag};
use self::maildir::MaildirType;
use super::email::{Envelope, EnvelopeHash, Flag};
use std::fmt;
use std::fmt::Debug;
use std::ops::Deref;
extern crate fnv;
use self::fnv::FnvHashMap;
use fnv::FnvHashMap;
use std;
pub type BackendCreator = Box<Fn(&AccountSettings) -> Box<MailBackend>>;
@ -209,7 +208,7 @@ pub trait BackendOp: ::std::fmt::Debug + ::std::marker::Send {
fn fetch_headers(&mut self) -> Result<&[u8]>;
fn fetch_body(&mut self) -> Result<&[u8]>;
fn fetch_flags(&self) -> Flag;
fn set_flag(&mut self, &mut Envelope, Flag) -> Result<()>;
fn set_flag(&mut self, envelope: &mut Envelope, flag: Flag) -> Result<()>;
}
/// `BackendOpGenerator` is a wrapper for a closure that returns a `BackendOp` object
@ -238,7 +237,7 @@ impl fmt::Debug for BackendOpGenerator {
pub trait BackendFolder: Debug {
fn hash(&self) -> FolderHash;
fn name(&self) -> &str;
fn change_name(&mut self, &str);
fn change_name(&mut self, new_name: &str);
fn clone(&self) -> Folder;
fn children(&self) -> &Vec<usize>;
}

10
melib/src/mailbox/backends/maildir.rs

@ -19,15 +19,13 @@
* along with meli. If not, see <http://www.gnu.org/licenses/>.
*/
extern crate fnv;
mod backend;
pub use self::backend::*;
use error::{MeliError, Result};
use mailbox::backends::*;
use mailbox::email::parser;
use mailbox::email::{Envelope, Flag};
use crate::error::{MeliError, Result};
use crate::mailbox::backends::*;
use crate::mailbox::email::parser;
use crate::mailbox::email::{Envelope, Flag};
use memmap::{Mmap, Protection};
use std::collections::hash_map::DefaultHasher;

20
melib/src/mailbox/backends/maildir/backend.rs

@ -19,22 +19,17 @@
* along with meli. If not, see <http://www.gnu.org/licenses/>.
*/
extern crate bincode;
extern crate fnv;
extern crate notify;
extern crate xdg;
use super::{MaildirFolder, MaildirOp};
use async::*;
use conf::AccountSettings;
use error::{MeliError, Result};
use mailbox::backends::{
use crate::async_workers::*;
use crate::conf::AccountSettings;
use crate::error::{MeliError, Result};
use super::{
BackendFolder, BackendOp, Folder, FolderHash, MailBackend, RefreshEvent, RefreshEventConsumer,
RefreshEventKind::*,
};
use mailbox::email::{Envelope, EnvelopeHash};
use crate::mailbox::email::{Envelope, EnvelopeHash};
use self::notify::{watcher, DebouncedEvent, RecursiveMode, Watcher};
use notify::{watcher, DebouncedEvent, RecursiveMode, Watcher};
use std::time::Duration;
use std::sync::mpsc::channel;
@ -42,8 +37,7 @@ use std::sync::mpsc::channel;
//use std::sync::mpsc::SyncSender;
//use std::time::Duration;
use std::thread;
extern crate crossbeam;
use self::fnv::{FnvHashMap, FnvHasher};
use fnv::{FnvHashMap, FnvHasher};
use std::collections::hash_map::DefaultHasher;
use std::ffi::OsStr;
use std::fs;

6
melib/src/mailbox/collection.rs

@ -1,14 +1,10 @@
extern crate bincode;
extern crate xdg;
use super::*;
use std::collections::BTreeMap;
use std::fs;
use std::io;
use std::ops::{Deref, DerefMut};
extern crate fnv;
use self::fnv::FnvHashMap;
use fnv::FnvHashMap;
/// `Mailbox` represents a folder of mail.
#[derive(Debug, Clone, Default)]

6
melib/src/mailbox/email.rs

@ -28,12 +28,12 @@ pub use self::compose::*;
mod attachment_types;
pub mod attachments;
pub use self::attachments::*;
pub use crate::attachments::*;
pub mod parser;
use parser::BytesExt;
use error::{MeliError, Result};
use mailbox::backends::BackendOp;
use crate::error::{MeliError, Result};
use super::backends::BackendOp;
use std::borrow::Cow;
use std::cmp::Ordering;

4
melib/src/mailbox/email/attachment_types.rs

@ -1,5 +1,5 @@
use mailbox::email::attachments::Attachment;
use mailbox::email::parser::BytesExt;
use crate::mailbox::email::attachments::Attachment;
use crate::mailbox::email::parser::BytesExt;
use std::fmt::{Display, Formatter, Result as FmtResult};
use std::str;

8
melib/src/mailbox/email/attachments.rs

@ -19,13 +19,13 @@
* along with meli. If not, see <http://www.gnu.org/licenses/>.
*/
use data_encoding::BASE64_MIME;
use mailbox::email::parser;
use mailbox::email::parser::BytesExt;
use mailbox::email::EnvelopeWrapper;
use crate::mailbox::email::parser;
use crate::mailbox::email::parser::BytesExt;
use crate::mailbox::email::EnvelopeWrapper;
use std::fmt;
use std::str;
pub use mailbox::email::attachment_types::*;
pub use crate::mailbox::email::attachment_types::*;
/*
*

6
melib/src/mailbox/email/compose.rs

@ -1,7 +1,7 @@
use super::*;
use chrono::{DateTime, Local};
use data_encoding::BASE64_MIME;
use mailbox::backends::BackendOp;
use crate::mailbox::backends::BackendOp;
use std::str;
mod mime;
@ -10,9 +10,7 @@ mod random;
//use self::mime::*;
use super::parser;
extern crate fnv;
use self::fnv::FnvHashMap;
use fnv::FnvHashMap;
#[derive(Debug, PartialEq)]
pub struct Draft {

7
melib/src/mailbox/thread.rs

@ -32,11 +32,10 @@
* user having mutable ownership.
*/
use mailbox::email::parser::BytesExt;
use mailbox::email::*;
use crate::mailbox::email::parser::BytesExt;
use crate::mailbox::email::*;
extern crate fnv;
use self::fnv::{FnvHashMap, FnvHashSet};
use fnv::{FnvHashMap, FnvHashSet};
use std::cell::{Ref, RefCell};
use std::cmp;
use std::cmp::Ordering;

8
src/bin.rs

@ -29,19 +29,19 @@ use std::alloc::System;
#[global_allocator]
static GLOBAL: System = System;
extern crate melib;
extern crate ui;
use ui;
pub use melib::*;
pub use ui::*;
#[macro_use]
extern crate chan;
extern crate chan_signal;
use chan_signal;
use chan_signal::Signal;
extern crate nix;
use nix;
fn main() {
/* Lock all stdio outs */

8
ui/src/conf/accounts.rs

@ -23,12 +23,12 @@
* Account management from user configuration.
*/
use async::*;
use conf::AccountConf;
use mailbox::backends::{
use melib::async_workers::{Async, AsyncStatus, AsyncBuilder};
use super::AccountConf;
use melib::mailbox::backends::{
Backends, Folder, MailBackend, NotifyFn, RefreshEvent, RefreshEventConsumer, RefreshEventKind,
};
use mailbox::*;
use melib::mailbox::*;
use melib::error::Result;
use melib::AddressBook;

2
ui/src/workers.rs

@ -1,5 +1,5 @@
use chan;
use melib::async::Work;
use melib::async_workers::Work;
use std;
use std::mem;
use std::thread;

Loading…
Cancel
Save