aboutsummaryrefslogtreecommitdiffstats
path: root/src/threads.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/threads.rs')
-rw-r--r--src/threads.rs29
1 files changed, 26 insertions, 3 deletions
diff --git a/src/threads.rs b/src/threads.rs
index 75f4549..5f62a8d 100644
--- a/src/threads.rs
+++ b/src/threads.rs
@@ -1,20 +1,21 @@
use std::{
ops,
marker,
+ iter
};
use utils::{
NewFromPtr,
};
-use database;
-
+use Database;
+use Thread;
use ffi;
#[derive(Debug)]
pub struct Threads<'d>(
*mut ffi::notmuch_threads_t,
- marker::PhantomData<&'d mut database::Database>,
+ marker::PhantomData<&'d mut Database>,
);
impl<'d> NewFromPtr<*mut ffi::notmuch_threads_t> for Threads<'d> {
@@ -30,3 +31,25 @@ impl<'d> ops::Drop for Threads<'d> {
};
}
}
+
+impl<'d> iter::Iterator for Threads<'d> {
+ type Item = Thread<'d>;
+
+ fn next(&mut self) -> Option<Self::Item> {
+
+ let valid = unsafe {
+ ffi::notmuch_threads_valid(self.0)
+ };
+
+ if valid == 0{
+ return None
+ }
+
+ let cthread = unsafe {
+ ffi::notmuch_threads_move_to_next(self.0);
+ ffi::notmuch_threads_get(self.0)
+ };
+
+ Some(Thread::new(cthread))
+ }
+}