aboutsummaryrefslogtreecommitdiffstats
path: root/src/thread.rs
diff options
context:
space:
mode:
authorDirk Van Haerenborgh <vhdirk@gmail.com>2018-12-20 08:21:03 +0100
committerDirk Van Haerenborgh <vhdirk@gmail.com>2018-12-20 08:21:03 +0100
commitbb8a60ddc9fdecc6c1004639514b538578e37532 (patch)
tree634968cabab56edec2f8a750903c155800a0f031 /src/thread.rs
parent2baa9d13ad4c5c2c6e55b6ca49c92a4d2434fba7 (diff)
downloadmail-bb8a60ddc9fdecc6c1004639514b538578e37532.tar.gz
remove ptr indirection
Diffstat (limited to 'src/thread.rs')
-rw-r--r--src/thread.rs44
1 files changed, 21 insertions, 23 deletions
diff --git a/src/thread.rs b/src/thread.rs
index 137c936..9634a57 100644
--- a/src/thread.rs
+++ b/src/thread.rs
@@ -9,25 +9,23 @@ use TagsOwner;
use Query;
#[derive(Debug)]
-pub(crate) struct ThreadPtr {
- pub ptr: *mut ffi::notmuch_thread_t,
-}
-
-impl Drop for ThreadPtr {
- fn drop(&mut self) {
- unsafe { ffi::notmuch_thread_destroy(self.ptr) };
- }
-}
-
-#[derive(Debug)]
pub struct Thread<'d, 'q>
where
'd: 'q
{
- pub(crate) handle: ThreadPtr,
+ pub(crate) ptr: *mut ffi::notmuch_thread_t,
pub(crate) marker: ScopedPhantomcow<'q, Query<'d>>,
}
+impl<'d, 'q> Drop for Thread<'d, 'q>
+where
+ 'd: 'q
+{
+ fn drop(&mut self) {
+ unsafe { ffi::notmuch_thread_destroy(self.ptr) };
+ }
+}
+
impl<'d, 'q> MessageOwner for Thread<'d, 'q> where 'd: 'q {}
impl<'d, 'q> TagsOwner for Thread<'d, 'q> where 'd: 'q {}
@@ -40,23 +38,23 @@ where
P: Into<ScopedPhantomcow<'q, Query<'d>>>,
{
Thread {
- handle: ThreadPtr { ptr },
+ ptr,
marker: owner.into(),
}
}
pub fn id(self: &Self) -> String {
- let tid = unsafe { ffi::notmuch_thread_get_thread_id(self.handle.ptr) };
+ let tid = unsafe { ffi::notmuch_thread_get_thread_id(self.ptr) };
tid.to_str().unwrap().to_string()
}
pub fn total_messages(self: &Self) -> i32 {
- unsafe { ffi::notmuch_thread_get_total_messages(self.handle.ptr) }
+ unsafe { ffi::notmuch_thread_get_total_messages(self.ptr) }
}
#[cfg(feature = "0.26")]
pub fn total_files(self: &Self) -> i32 {
- unsafe { ffi::notmuch_thread_get_total_files(self.handle.ptr) }
+ unsafe { ffi::notmuch_thread_get_total_files(self.ptr) }
}
pub fn toplevel_messages(self: &Self) -> Messages<'_, Self> {
@@ -74,13 +72,13 @@ where
}
pub fn subject(self: &Self) -> String {
- let sub = unsafe { ffi::notmuch_thread_get_subject(self.handle.ptr) };
+ let sub = unsafe { ffi::notmuch_thread_get_subject(self.ptr) };
sub.to_str().unwrap().to_string()
}
pub fn authors(self: &Self) -> Vec<String> {
- let athrs = unsafe { ffi::notmuch_thread_get_authors(self.handle.ptr) };
+ let athrs = unsafe { ffi::notmuch_thread_get_authors(self.ptr) };
athrs
.to_str()
@@ -92,12 +90,12 @@ where
/// Get the date of the oldest message in 'thread' as a time_t value.
pub fn oldest_date(self: &Self) -> i64 {
- unsafe { ffi::notmuch_thread_get_oldest_date(self.handle.ptr) as i64 }
+ unsafe { ffi::notmuch_thread_get_oldest_date(self.ptr) as i64 }
}
/// Get the date of the newest message in 'thread' as a time_t value.
pub fn newest_date(self: &Self) -> i64 {
- unsafe { ffi::notmuch_thread_get_newest_date(self.handle.ptr) as i64 }
+ unsafe { ffi::notmuch_thread_get_newest_date(self.ptr) as i64 }
}
}
@@ -111,7 +109,7 @@ where
{
let threadref = thread.into();
Tags::from_ptr(
- unsafe { ffi::notmuch_thread_get_tags(threadref.handle.ptr) },
+ unsafe { ffi::notmuch_thread_get_tags(threadref.ptr) },
ScopedSupercow::phantom(threadref),
)
}
@@ -122,7 +120,7 @@ where
{
let threadref = thread.into();
Messages::from_ptr(
- unsafe { ffi::notmuch_thread_get_toplevel_messages(threadref.handle.ptr) },
+ unsafe { ffi::notmuch_thread_get_toplevel_messages(threadref.ptr) },
ScopedSupercow::phantom(threadref),
)
}
@@ -135,7 +133,7 @@ where
{
let threadref = thread.into();
Messages::from_ptr(
- unsafe { ffi::notmuch_thread_get_messages(threadref.handle.ptr) },
+ unsafe { ffi::notmuch_thread_get_messages(threadref.ptr) },
ScopedSupercow::phantom(threadref),
)
}