aboutsummaryrefslogtreecommitdiffstats
path: root/tests/main.rs
blob: 512aa84ee175791030f63e93ab797c67fa35c690 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
extern crate notmuch;
extern crate dirs;

use std::sync::Arc;

use notmuch::{StreamingIterator, StreamingIteratorExt};
use notmuch::{Threads, Thread, Query, QueryExt};

fn main() {

    let mut mail_path = dirs::home_dir().unwrap();
    mail_path.push(".mail");

    match notmuch::Database::open(&mail_path.to_str().unwrap().to_string(), notmuch::DatabaseMode::ReadOnly){
        Ok(db) => {
            
            #[cfg(feature = "v0_21")]
            {
                let rev = db.revision();
                println!("db revision: {:?}", rev);
            }
            let query = {
                let dbr = Arc::new(db);

                notmuch::Query::create(dbr.clone(), &"".to_string()).unwrap()
            };


            // let mut threads = query.search_threads().unwrap();


            
            // let mut threads = db.create_query(&"".to_string()).unwrap().search_threads().unwrap();

            let threads = Arc::new(<Query as QueryExt>::search_threads(query).unwrap());


            while let Some(thread) = <Threads<Query> as StreamingIteratorExt<Thread<Threads<Query>>>>::next(threads.clone()) {
                println!("thread {:?} {:?}", thread.subject(), thread.authors());
            }


        },
        Err(err) =>{
            println!("Got error while trying to open db: {:?}", err);
        }
    }
}