aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorC. Morgan Hamill <me@cmhamill.org>2015-03-19 16:54:16 +0100
committerC. Morgan Hamill <me@cmhamill.org>2015-03-19 19:02:16 +0100
commit2c0a26ddf8385a4363cb8d4c54259abb33932ea8 (patch)
tree2057021cad629b2c1a58f0a3f412f924248e21c5
parentacb67e3d7fef9e83e0be3150d42af3dd02e33fa6 (diff)
downloadmail-2c0a26ddf8385a4363cb8d4c54259abb33932ea8.tar.gz
Add convenience methods to `notmuch_status_t`.
Convenience methods for working the result of many of the native notmuch functions.
-rw-r--r--src/ffi.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/ffi.rs b/src/ffi.rs
index 9cc6f47..2ee99e0 100644
--- a/src/ffi.rs
+++ b/src/ffi.rs
@@ -39,6 +39,21 @@ notmuch_enum! {
NOTMUCH_STATUS_LAST_STATUS => LastStatus
}
}
+
+impl notmuch_status_t {
+ pub fn is_ok(&self) -> bool {
+ match *self {
+ notmuch_status_t::NOTMUCH_STATUS_SUCCESS => true,
+ _ => false,
+ }
+ }
+
+ pub fn as_result(self) -> Result<(), Self> {
+ match self.is_ok() {
+ true => Ok(()),
+ false => Err(self),
+ }
+ }
}
notmuch_enum! {