aboutsummaryrefslogtreecommitdiffstats
path: root/src/message.rs
diff options
context:
space:
mode:
authorDirk Van Haerenborgh <vhdirk@gmail.com>2018-12-17 18:29:55 +0100
committerDirk Van Haerenborgh <vhdirk@gmail.com>2018-12-17 18:29:55 +0100
commitd74e6fee5dc34e8015f4d9699b5624d7a60a3c8a (patch)
treefefa2c6d2c312385986364eddcab9a02f53d966a /src/message.rs
parent0d510d55c4238ff0a1175985b27ca38c71a3cfc2 (diff)
downloadmail-d74e6fee5dc34e8015f4d9699b5624d7a60a3c8a.tar.gz
Revert "link lifetime of message to Query"
This reverts commit 0d510d55c4238ff0a1175985b27ca38c71a3cfc2.
Diffstat (limited to 'src/message.rs')
-rw-r--r--src/message.rs71
1 files changed, 33 insertions, 38 deletions
diff --git a/src/message.rs b/src/message.rs
index 80e7c46..8cc7af2 100644
--- a/src/message.rs
+++ b/src/message.rs
@@ -10,7 +10,6 @@ use FilenamesOwner;
use Messages;
use Tags;
use TagsOwner;
-use Query;
pub trait MessageOwner: Send + Sync {}
@@ -20,25 +19,25 @@ pub(crate) struct MessagePtr {
}
#[derive(Debug)]
-pub struct Message<'d, 'q>
+pub struct Message<'o, O>
where
- 'd: 'q,
+ O: MessageOwner + 'o,
{
pub(crate) handle: MessagePtr,
- marker: ScopedPhantomcow<'q, Query<'d>>,
+ marker: ScopedPhantomcow<'o, O>,
}
-impl<'d, 'q> MessageOwner for Message<'d, 'q> where 'd: 'q {}
-impl<'d, 'q> FilenamesOwner for Message<'d, 'q> where 'd: 'q {}
-impl<'d, 'q> TagsOwner for Message<'d, 'q> where 'd: 'q {}
+impl<'o, O> MessageOwner for Message<'o, O> where O: MessageOwner + 'o {}
+impl<'o, O> FilenamesOwner for Message<'o, O> where O: MessageOwner + 'o {}
+impl<'o, O> TagsOwner for Message<'o, O> where O: MessageOwner + 'o {}
-impl<'d, 'q> Message<'d, 'q>
+impl<'o, O> Message<'o, O>
where
- 'd: 'q,
+ O: MessageOwner + 'o,
{
- pub fn from_ptr<P>(ptr: *mut ffi::notmuch_message_t, owner: P) -> Message<'d, 'q>
+ pub fn from_ptr<P>(ptr: *mut ffi::notmuch_message_t, owner: P) -> Message<'o, O>
where
- P: Into<ScopedPhantomcow<'q, Query<'d>>>,
+ P: Into<ScopedPhantomcow<'o, O>>,
{
Message {
handle: MessagePtr { ptr },
@@ -56,12 +55,8 @@ where
tid.to_str().unwrap().to_string()
}
- pub fn replies(self: &mut Self) -> Messages<'d, 'q>
- {
- Messages::from_ptr(
- unsafe { ffi::notmuch_message_get_replies(self.handle.ptr) },
- ScopedPhantomcow::<'q, Query<'d>>::share(&mut self.marker),
- )
+ pub fn replies(self: &Self) -> Messages<Self> {
+ <Self as MessageExt<'o, O>>::replies(self)
}
#[cfg(feature = "v0_26")]
@@ -70,7 +65,7 @@ where
}
pub fn filenames(self: &Self) -> Filenames<Self> {
- <Self as MessageExt<'d, 'q>>::filenames(self)
+ <Self as MessageExt<'o, O>>::filenames(self)
}
pub fn filename(self: &Self) -> PathBuf {
@@ -99,7 +94,7 @@ where
}
pub fn tags(&self) -> Tags<Self> {
- <Self as MessageExt<'d, 'q>>::tags(self)
+ <Self as MessageExt<'o, O>>::tags(self)
}
pub fn add_tag(self: &Self, tag: &str) -> Result<()> {
@@ -117,13 +112,13 @@ where
}
}
-pub trait MessageExt<'d, 'q>
+pub trait MessageExt<'o, O>
where
- 'd: 'q,
+ O: MessageOwner + 'o,
{
- fn tags<'s, S>(message: S) -> Tags<'s, Message<'d, 'q>>
+ fn tags<'s, S>(message: S) -> Tags<'s, Message<'o, O>>
where
- S: Into<ScopedSupercow<'s, Message<'d, 'q>>>,
+ S: Into<ScopedSupercow<'s, Message<'o, O>>>,
{
let messageref = message.into();
Tags::from_ptr(
@@ -132,20 +127,20 @@ where
)
}
- // fn replies<'s, S>(message: S) -> Messages<'d, 'q>
- // where
- // S: Into<ScopedSupercow<'s, Message<'d, 'q>>>,
- // {
- // let messageref = message.into();
- // Messages::from_ptr(
- // unsafe { ffi::notmuch_message_get_replies(messageref.handle.ptr) },
- // Supercow::phantom(messageref),
- // )
- // }
+ fn replies<'s, S>(message: S) -> Messages<'s, Message<'o, O>>
+ where
+ S: Into<ScopedSupercow<'s, Message<'o, O>>>,
+ {
+ let messageref = message.into();
+ Messages::from_ptr(
+ unsafe { ffi::notmuch_message_get_replies(messageref.handle.ptr) },
+ Supercow::phantom(messageref),
+ )
+ }
- fn filenames<'s, S>(message: S) -> Filenames<'s, Message<'d, 'q>>
+ fn filenames<'s, S>(message: S) -> Filenames<'s, Message<'o, O>>
where
- S: Into<ScopedSupercow<'s, Message<'d, 'q>>>,
+ S: Into<ScopedSupercow<'s, Message<'o, O>>>,
{
let messageref = message.into();
Filenames::from_ptr(
@@ -155,7 +150,7 @@ where
}
}
-impl<'d, 'q> MessageExt<'d, 'q> for Message<'d, 'q> where 'd: 'q {}
+impl<'o, O> MessageExt<'o, O> for Message<'o, O> where O: MessageOwner + 'o {}
-unsafe impl<'d, 'q> Send for Message<'d, 'q> where 'd: 'q {}
-unsafe impl<'d, 'q> Sync for Message<'d, 'q> where 'd: 'q {}
+unsafe impl<'o, O> Send for Message<'o, O> where O: MessageOwner + 'o {}
+unsafe impl<'o, O> Sync for Message<'o, O> where O: MessageOwner + 'o {}