From 2c0a26ddf8385a4363cb8d4c54259abb33932ea8 Mon Sep 17 00:00:00 2001 From: "C. Morgan Hamill" Date: Thu, 19 Mar 2015 11:54:16 -0400 Subject: Add convenience methods to `notmuch_status_t`. Convenience methods for working the result of many of the native notmuch functions. --- src/ffi.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/ffi.rs') 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! { -- cgit v1.2.1