blob: f07002093709c80cea7c80cb02f1327582781248 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
use std::ops::Drop;
use supercow::{Supercow, Phantomcow};
use error::{Error, Result};
use ffi;
use ffi::DecryptionPolicy;
use Database;
use Filenames;
use FilenamesOwner;
use utils::{ScopedSupercow, 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> {}
|