diff options
| author | C. Morgan Hamill <me@cmhamill.org> | 2015-03-19 16:54:16 +0100 |
|---|---|---|
| committer | C. Morgan Hamill <me@cmhamill.org> | 2015-03-19 19:02:16 +0100 |
| commit | 2c0a26ddf8385a4363cb8d4c54259abb33932ea8 (patch) | |
| tree | 2057021cad629b2c1a58f0a3f412f924248e21c5 | |
| parent | acb67e3d7fef9e83e0be3150d42af3dd02e33fa6 (diff) | |
| download | mail-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.rs | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -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! { |
