From 9b0d6458bdac2d9cc99a0fc2abbfd11a2c7115d2 Mon Sep 17 00:00:00 2001 From: Dirk Van Haerenborgh Date: Fri, 18 Oct 2019 15:11:26 +0200 Subject: query: implement add_tag_exclude --- src/ffi.rs | 2 +- src/query.rs | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ffi.rs b/src/ffi.rs index 7533b06..6075014 100644 --- a/src/ffi.rs +++ b/src/ffi.rs @@ -674,7 +674,7 @@ extern "C" { /// Add a tag that will be excluded from the query results by default. /// This exclusion will be overridden if this tag appears explicitly in /// the query. - pub fn notmuch_query_add_tag_exclude(query: *mut notmuch_query_t, tag: *const c_char); + pub fn notmuch_query_add_tag_exclude(query: *mut notmuch_query_t, tag: *const c_char) -> notmuch_status_t; /// Execute a query for threads, returning a `notmuch_threads_t` object /// which can be used to iterate over the results. The returned threads diff --git a/src/query.rs b/src/query.rs index 127a9ab..f9afed5 100644 --- a/src/query.rs +++ b/src/query.rs @@ -1,5 +1,6 @@ use std::ops::Drop; use std::ptr; +use std::ffi::{CStr, CString}; use supercow::{Phantomcow, Supercow}; @@ -78,6 +79,12 @@ impl<'d> Query<'d> { Ok(cnt) } + + pub fn add_tag_exclude(self: &Self, tag: &str) -> Result<()> + { + let tag_str = CString::new(tag).unwrap(); + unsafe { ffi::notmuch_query_add_tag_exclude(self.ptr, tag_str.as_ptr()) }.as_result() + } } pub trait QueryExt<'d> { -- cgit v1.2.1