aboutsummaryrefslogtreecommitdiffstats
path: root/src/thread.rs
diff options
context:
space:
mode:
authorDirk Van Haerenborgh <vhdirk@gmail.com>2018-12-14 18:45:20 +0100
committerDirk Van Haerenborgh <vhdirk@gmail.com>2018-12-14 18:45:20 +0100
commit4b19b951dd2fb7aa7bc662170c91401f2e8fac3b (patch)
tree5b436865f4ae78a90129147e1a0fd8b53b2746b2 /src/thread.rs
parent022fb6eebf7774b19a1e1b3c6cee7bd7e1b75cd9 (diff)
downloadmail-4b19b951dd2fb7aa7bc662170c91401f2e8fac3b.tar.gz
remove StreamingIterator again as the iterators don't actually have ownership over items
Diffstat (limited to 'src/thread.rs')
-rw-r--r--src/thread.rs32
1 files changed, 12 insertions, 20 deletions
diff --git a/src/thread.rs b/src/thread.rs
index 3b58a3e..9569cbc 100644
--- a/src/thread.rs
+++ b/src/thread.rs
@@ -2,37 +2,29 @@ use std::ops::Drop;
use supercow::{Phantomcow, Supercow};
use crate::ffi;
-use crate::utils::ToStr;
+use crate::utils::{ToStr, ScopedSupercow, ScopedPhantomcow};
use crate::Messages;
-use crate::MessagesOwner;
+use crate::MessageOwner;
use crate::Tags;
use crate::TagsOwner;
-pub trait ThreadOwner {}
+pub trait ThreadOwner: Send + Sync {}
#[derive(Debug)]
pub(crate) struct ThreadPtr {
pub ptr: *mut ffi::notmuch_thread_t,
}
-// TODO: The iterator doesn't actually own these, so dropping these will
-// generate a segfault when a new iterator is constructed.
-// impl Drop for ThreadPtr {
-// fn drop(&mut self) {
-// unsafe { ffi::notmuch_thread_destroy(self.ptr) };
-// }
-// }
-
#[derive(Debug)]
pub struct Thread<'o, O>
where
O: ThreadOwner,
{
pub(crate) handle: ThreadPtr,
- marker: Phantomcow<'o, O>,
+ pub(crate) marker: ScopedPhantomcow<'o, O>,
}
-impl<'o, O> MessagesOwner for Thread<'o, O> where O: ThreadOwner + 'o {}
+impl<'o, O> MessageOwner for Thread<'o, O> where O: ThreadOwner + 'o {}
impl<'o, O> TagsOwner for Thread<'o, O> where O: ThreadOwner + 'o {}
impl<'o, O> Thread<'o, O>
@@ -41,7 +33,7 @@ where
{
pub fn from_ptr<P>(ptr: *mut ffi::notmuch_thread_t, owner: P) -> Thread<'o, O>
where
- P: Into<Phantomcow<'o, O>>,
+ P: Into<ScopedPhantomcow<'o, O>>,
{
Thread {
handle: ThreadPtr { ptr },
@@ -111,23 +103,23 @@ where
{
fn tags<'s, S>(thread: S) -> Tags<'s, Thread<'o, O>>
where
- S: Into<Supercow<'s, Thread<'o, O>>>,
+ S: Into<ScopedSupercow<'s, Thread<'o, O>>>,
{
let threadref = thread.into();
Tags::from_ptr(
unsafe { ffi::notmuch_thread_get_tags(threadref.handle.ptr) },
- Supercow::phantom(threadref),
+ ScopedSupercow::phantom(threadref),
)
}
fn toplevel_messages<'s, S>(thread: S) -> Messages<'s, Thread<'o, O>>
where
- S: Into<Supercow<'s, Thread<'o, O>>>,
+ S: Into<ScopedSupercow<'s, Thread<'o, O>>>,
{
let threadref = thread.into();
Messages::from_ptr(
unsafe { ffi::notmuch_thread_get_toplevel_messages(threadref.handle.ptr) },
- Supercow::phantom(threadref),
+ ScopedSupercow::phantom(threadref),
)
}
@@ -135,12 +127,12 @@ where
/// oldest-first order.
fn messages<'s, S>(thread: S) -> Messages<'s, Thread<'o, O>>
where
- S: Into<Supercow<'s, Thread<'o, O>>>,
+ S: Into<ScopedSupercow<'s, Thread<'o, O>>>,
{
let threadref = thread.into();
Messages::from_ptr(
unsafe { ffi::notmuch_thread_get_messages(threadref.handle.ptr) },
- Supercow::phantom(threadref),
+ ScopedSupercow::phantom(threadref),
)
}
}