aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ffi.rs32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/ffi.rs b/src/ffi.rs
index 2ee99e0..45a1f17 100644
--- a/src/ffi.rs
+++ b/src/ffi.rs
@@ -11,7 +11,17 @@ use libc::{
time_t,
};
-use utils::NotmuchEnum;
+use std::{
+ error,
+ fmt,
+ str,
+};
+
+use utils::{
+ NotmuchEnum,
+ ToStaticStr,
+ ToStr,
+};
pub type notmuch_bool_t = c_int;
@@ -56,6 +66,26 @@ impl notmuch_status_t {
}
}
+impl ToStr for NotmuchStatus {
+ fn to_str(&self) -> Result<&str, str::Utf8Error> {
+ unsafe {
+ notmuch_status_to_string(self.to_notmuch_t())
+ }.to_static_str()
+ }
+}
+
+impl fmt::Display for NotmuchStatus {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ write!(f, "{}", self.to_str().unwrap())
+ }
+}
+
+impl error::Error for NotmuchStatus {
+ fn description(&self) -> &str {
+ self.to_str().unwrap()
+ }
+}
+
notmuch_enum! {
#[repr(C)]
#[derive(Copy, Debug)]