aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/ffi.rs4
-rw-r--r--src/message.rs12
-rw-r--r--src/messages.rs16
-rw-r--r--src/thread.rs19
-rw-r--r--src/threads.rs16
5 files changed, 39 insertions, 28 deletions
diff --git a/src/ffi.rs b/src/ffi.rs
index 58965cc..765b180 100644
--- a/src/ffi.rs
+++ b/src/ffi.rs
@@ -54,6 +54,10 @@ impl notmuch_status_t {
}
}
+ pub fn is_err(&self) -> bool {
+ !self.is_ok()
+ }
+
pub fn as_result(self) -> Result<(), Self> {
match self.is_ok() {
true => Ok(()),
diff --git a/src/message.rs b/src/message.rs
index d774043..79fb19c 100644
--- a/src/message.rs
+++ b/src/message.rs
@@ -11,22 +11,22 @@ use ffi;
use utils::{
NewFromPtr,
};
-use Database;
+use Query;
#[derive(Debug)]
-pub struct Message<'d>(
+pub struct Message<'q, 'd:'q>(
pub(crate) *mut ffi::notmuch_message_t,
- marker::PhantomData<&'d mut Database>,
+ marker::PhantomData<&'q mut Query<'d>>,
);
-impl<'d> NewFromPtr<*mut ffi::notmuch_message_t> for Message<'d> {
- fn new(ptr: *mut ffi::notmuch_message_t) -> Message<'d> {
+impl<'q, 'd> NewFromPtr<*mut ffi::notmuch_message_t> for Message<'q, 'd> {
+ fn new(ptr: *mut ffi::notmuch_message_t) -> Message<'q, 'd> {
Message(ptr, marker::PhantomData)
}
}
-impl<'d> ops::Drop for Message<'d> {
+impl<'q, 'd> ops::Drop for Message<'q, 'd> {
fn drop(&mut self) {
unsafe {
ffi::notmuch_message_destroy(self.0)
diff --git a/src/messages.rs b/src/messages.rs
index 706cfda..bb86866 100644
--- a/src/messages.rs
+++ b/src/messages.rs
@@ -10,24 +10,24 @@ use ffi;
use utils::{
NewFromPtr,
};
-use Database;
+use Query;
use Message;
#[derive(Debug)]
-pub struct Messages<'d>(
+pub struct Messages<'q, 'd:'q>(
// TODO: is this lifetime specifier correct?
// query may outlive messages.
pub(crate) *mut ffi::notmuch_messages_t,
- marker::PhantomData<&'d mut Database>,
+ marker::PhantomData<&'q mut Query<'d>>,
);
-impl<'d> NewFromPtr<*mut ffi::notmuch_messages_t> for Messages<'d> {
- fn new(ptr: *mut ffi::notmuch_messages_t) -> Messages<'d> {
+impl<'q, 'd> NewFromPtr<*mut ffi::notmuch_messages_t> for Messages<'q, 'd> {
+ fn new(ptr: *mut ffi::notmuch_messages_t) -> Messages<'q, 'd> {
Messages(ptr, marker::PhantomData)
}
}
-impl<'d> ops::Drop for Messages<'d> {
+impl<'q, 'd> ops::Drop for Messages<'q, 'd> {
fn drop(&mut self) {
unsafe {
ffi::notmuch_messages_destroy(self.0)
@@ -35,8 +35,8 @@ impl<'d> ops::Drop for Messages<'d> {
}
}
-impl<'d> iter::Iterator for Messages<'d> {
- type Item = Message<'d>;
+impl<'q, 'd> iter::Iterator for Messages<'q, 'd> {
+ type Item = Message<'q, 'd>;
fn next(&mut self) -> Option<Self::Item> {
diff --git a/src/thread.rs b/src/thread.rs
index 980ff39..cf5440c 100644
--- a/src/thread.rs
+++ b/src/thread.rs
@@ -11,21 +11,28 @@ use ffi;
use utils::{
NewFromPtr,
};
-use Database;
+use Query;
#[derive(Debug)]
-pub struct Thread<'d>(
+pub struct Thread<'q, 'd:'q>(
pub(crate) *mut ffi::notmuch_thread_t,
- marker::PhantomData<&'d mut Database>,
+ marker::PhantomData<&'q mut Query<'d>>,
);
-impl<'d> NewFromPtr<*mut ffi::notmuch_thread_t> for Thread<'d> {
- fn new(ptr: *mut ffi::notmuch_thread_t) -> Thread<'d> {
+impl<'q, 'd> NewFromPtr<*mut ffi::notmuch_thread_t> for Thread<'q, 'd> {
+ fn new(ptr: *mut ffi::notmuch_thread_t) -> Thread<'q, 'd> {
Thread(ptr, marker::PhantomData)
}
}
-impl<'d> ops::Drop for Thread<'d> {
+// impl<'d> Thread<'d>(
+//
+//
+//
+// };
+//
+
+impl<'q, 'd> ops::Drop for Thread<'q, 'd> {
fn drop(&mut self) {
unsafe {
ffi::notmuch_thread_destroy(self.0)
diff --git a/src/threads.rs b/src/threads.rs
index 5f62a8d..eb8452e 100644
--- a/src/threads.rs
+++ b/src/threads.rs
@@ -8,23 +8,23 @@ use utils::{
NewFromPtr,
};
-use Database;
+use Query;
use Thread;
use ffi;
#[derive(Debug)]
-pub struct Threads<'d>(
+pub struct Threads<'q, 'd:'q>(
*mut ffi::notmuch_threads_t,
- marker::PhantomData<&'d mut Database>,
+ marker::PhantomData<&'q mut Query<'d>>,
);
-impl<'d> NewFromPtr<*mut ffi::notmuch_threads_t> for Threads<'d> {
- fn new(ptr: *mut ffi::notmuch_threads_t) -> Threads<'d> {
+impl<'q, 'd> NewFromPtr<*mut ffi::notmuch_threads_t> for Threads<'q, 'd> {
+ fn new(ptr: *mut ffi::notmuch_threads_t) -> Threads<'q, 'd> {
Threads(ptr, marker::PhantomData)
}
}
-impl<'d> ops::Drop for Threads<'d> {
+impl<'q, 'd> ops::Drop for Threads<'q, 'd> {
fn drop(&mut self) {
unsafe {
ffi::notmuch_threads_destroy(self.0)
@@ -32,8 +32,8 @@ impl<'d> ops::Drop for Threads<'d> {
}
}
-impl<'d> iter::Iterator for Threads<'d> {
- type Item = Thread<'d>;
+impl<'q, 'd> iter::Iterator for Threads<'q, 'd> {
+ type Item = Thread<'q, 'd>;
fn next(&mut self) -> Option<Self::Item> {