diff options
| author | Dirk Van Haerenborgh <vhdirk@gmail.com> | 2019-10-23 06:55:03 +0200 |
|---|---|---|
| committer | Dirk Van Haerenborgh <vhdirk@gmail.com> | 2019-10-23 06:55:03 +0200 |
| commit | edf986b7888a97ad434f08c1900d5ae4356ec44a (patch) | |
| tree | 57ee903330f43cd61f6c53ab013bfc5088b638b6 | |
| parent | 1e4e67fde1a7c75c9a81312d71340801d0ee06d3 (diff) | |
| download | mail-edf986b7888a97ad434f08c1900d5ae4356ec44a.tar.gz | |
fix index_file and add freeze/thaw
| -rw-r--r-- | src/database.rs | 18 | ||||
| -rw-r--r-- | src/lib.rs | 4 | ||||
| -rw-r--r-- | src/message.rs | 8 |
3 files changed, 22 insertions, 8 deletions
diff --git a/src/database.rs b/src/database.rs index c26b5a8..f3733ef 100644 --- a/src/database.rs +++ b/src/database.rs @@ -249,12 +249,20 @@ impl Database { <Self as DatabaseExt>::get_default_indexopts(self) } - pub fn index_file<'d, P>(&'d self, path: &P, indexopts: Option<IndexOpts<'d>>) -> Result<Option<Message<'d, Self>>> + pub fn index_file<'d, P>(&'d self, path: &P, indexopts: Option<IndexOpts<'d>>) -> Result<Message<'d, Self>> where P: AsRef<Path>, { <Self as DatabaseExt>::index_file(self, path, indexopts) } + + pub fn begin_atomic(&self) -> Result<()> { + unsafe { ffi::notmuch_database_begin_atomic(self.ptr) }.as_result() + } + + pub fn end_atomic(&self) -> Result<()> { + unsafe { ffi::notmuch_database_end_atomic(self.ptr) }.as_result() + } } pub trait DatabaseExt { @@ -370,7 +378,7 @@ pub trait DatabaseExt { } - fn index_file<'d, D, P>(database: D, path: &P, indexopts: Option<IndexOpts<'d>>) -> Result<Option<Message<'d, Database>>> + fn index_file<'d, D, P>(database: D, path: &P, indexopts: Option<IndexOpts<'d>>) -> Result<Message<'d, Database>> where D: Into<ScopedSupercow<'d, Database>>, P: AsRef<Path>, @@ -387,11 +395,7 @@ pub trait DatabaseExt { unsafe { ffi::notmuch_database_index_file(dbref.ptr, msg_path.as_ptr(), opts, &mut msg) } .as_result()?; - if msg.is_null() { - Ok(None) - } else { - Ok(Some(Message::from_ptr(msg, Supercow::phantom(dbref)))) - } + Ok(Message::from_ptr(msg, Supercow::phantom(dbref))) } None => Err(Error::NotmuchError(Status::FileError)), } @@ -34,4 +34,6 @@ pub use thread::{Thread, ThreadExt}; pub use threads::{Threads, ThreadsExt}; pub use index::IndexOpts; -pub use ffi::{DatabaseMode, Sort, DecryptionPolicy};
\ No newline at end of file +pub use ffi::{DatabaseMode, Sort, DecryptionPolicy}; + +pub use utils::{ScopedSupercow, ScopedPhantomcow};
\ No newline at end of file diff --git a/src/message.rs b/src/message.rs index 73727f9..f5d0542 100644 --- a/src/message.rs +++ b/src/message.rs @@ -123,6 +123,14 @@ where pub fn reindex<'d>(self: &Self, indexopts: IndexOpts<'d>) -> Result<()> { unsafe { ffi::notmuch_message_reindex(self.ptr, indexopts.ptr) }.as_result() } + + pub fn freeze(self: &Self) -> Result<()> { + unsafe { ffi::notmuch_message_freeze(self.ptr) }.as_result() + } + + pub fn thaw(self: &Self) -> Result<()> { + unsafe { ffi::notmuch_message_thaw(self.ptr) }.as_result() + } } pub trait MessageExt<'o, O> |
