aboutsummaryrefslogtreecommitdiffstats
path: root/notmuch/src/index.rs
diff options
context:
space:
mode:
Diffstat (limited to 'notmuch/src/index.rs')
-rw-r--r--notmuch/src/index.rs43
1 files changed, 43 insertions, 0 deletions
diff --git a/notmuch/src/index.rs b/notmuch/src/index.rs
new file mode 100644
index 0000000..4db6bc7
--- /dev/null
+++ b/notmuch/src/index.rs
@@ -0,0 +1,43 @@
+use std::ops::Drop;
+
+use error::Result;
+use ffi;
+use ffi::DecryptionPolicy;
+use Database;
+use utils::ScopedPhantomcow;
+
+
+#[derive(Debug)]
+pub struct IndexOpts<'d> {
+ pub(crate) ptr: *mut ffi::notmuch_indexopts_t,
+ marker: ScopedPhantomcow<'d, Database>,
+}
+
+impl<'d> Drop for IndexOpts<'d> {
+ fn drop(&mut self) {
+ unsafe { ffi::notmuch_indexopts_destroy(self.ptr) };
+ }
+}
+
+impl<'d> IndexOpts<'d> {
+ pub(crate) fn from_ptr<O>(ptr: *mut ffi::notmuch_indexopts_t, owner: O) -> IndexOpts<'d>
+ where
+ O: Into<ScopedPhantomcow<'d, Database>>,
+ {
+ IndexOpts {
+ ptr,
+ marker: owner.into(),
+ }
+ }
+
+ pub fn set_decrypt_policy(self: &Self, decrypt_policy: DecryptionPolicy) -> Result<()> {
+ unsafe { ffi::notmuch_indexopts_set_decrypt_policy(self.ptr, decrypt_policy.into()) }.as_result()
+ }
+
+ pub fn decrypt_policy(self: &Self) -> DecryptionPolicy {
+ unsafe { ffi::notmuch_indexopts_get_decrypt_policy(self.ptr)}.into()
+ }
+}
+
+unsafe impl<'d> Send for IndexOpts<'d> {}
+unsafe impl<'d> Sync for IndexOpts<'d> {} \ No newline at end of file