diff options
Diffstat (limited to 'src/query.rs')
| -rw-r--r-- | src/query.rs | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/src/query.rs b/src/query.rs index 24a2a1b..18d44d7 100644 --- a/src/query.rs +++ b/src/query.rs @@ -1,24 +1,38 @@ use std::{ ops, + marker }; use error::Result; use ffi; +use utils::{ + NewFromPtr, +}; +use Database; -use database::Database; #[derive(Debug)] -pub struct Query(pub(crate) *mut ffi::notmuch_query_t); +pub struct Query<'d>( + pub(crate) *mut ffi::notmuch_query_t, + marker::PhantomData<&'d mut Database>, +); + -impl Query { - pub fn create(db: &Database, query_string: &String) -> Result<Self> { +impl<'d> Query<'d> { + pub fn create(db: &'d Database, query_string: &String) -> Result<Self> { db.create_query(query_string) } } +impl<'d> NewFromPtr<*mut ffi::notmuch_query_t> for Query<'d> { + fn new(ptr: *mut ffi::notmuch_query_t) -> Query<'d> { + Query(ptr, marker::PhantomData) + } +} + -impl ops::Drop for Query { +impl<'d> ops::Drop for Query<'d> { fn drop(&mut self) { unsafe { ffi::notmuch_query_destroy(self.0) |
