diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/database.rs | 3 | ||||
| -rw-r--r-- | src/error.rs | 3 | ||||
| -rw-r--r-- | src/ffi.rs | 3 | ||||
| -rw-r--r-- | src/macros.rs | 12 | ||||
| -rw-r--r-- | src/utils.rs | 7 |
5 files changed, 9 insertions, 19 deletions
diff --git a/src/database.rs b/src/database.rs index 6b0542d..d082f3a 100644 --- a/src/database.rs +++ b/src/database.rs @@ -8,7 +8,6 @@ use libc; use error::Result; use utils::{ - NotmuchType, ToCString, ToStr, }; @@ -41,7 +40,7 @@ impl Database { let mut db = ptr::null_mut(); try!(unsafe { ffi::notmuch_database_open( - path.as_ptr(), mode.to_notmuch_t(), &mut db, + path.as_ptr(), mode.into(), &mut db, ) }.as_result()); diff --git a/src/error.rs b/src/error.rs index 22c1f6e..01c28fb 100644 --- a/src/error.rs +++ b/src/error.rs @@ -5,7 +5,6 @@ use std::{ result, }; -use utils::NotmuchType; use ffi; pub type Result<T> = result::Result<T, Error>; @@ -52,6 +51,6 @@ impl error::FromError<ffi::NotmuchStatus> for Error { impl error::FromError<ffi::notmuch_status_t> for Error { fn from_error(err: ffi::notmuch_status_t) -> Error { - Error::NotmuchError(ffi::NotmuchStatus::from_notmuch_t(err)) + Error::NotmuchError(ffi::NotmuchStatus::from(err)) } } @@ -18,7 +18,6 @@ use std::{ }; use utils::{ - NotmuchType, ToStr, }; @@ -68,7 +67,7 @@ impl notmuch_status_t { impl ToStr for NotmuchStatus { fn to_str<'a>(&self) -> Result<&'a str, str::Utf8Error> { unsafe { - notmuch_status_to_string(self.to_notmuch_t()) + notmuch_status_to_string((*self).into()) }.to_str() } } diff --git a/src/macros.rs b/src/macros.rs index 8802a71..a36197b 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -16,16 +16,16 @@ macro_rules! notmuch_enum { $($variant_alias),* } - impl NotmuchType for $name_alias { - type NotmuchT = $name; - - fn from_notmuch_t(notmuch_t: $name) -> Self { - match notmuch_t { + impl From<$name> for $name_alias { + fn from(t: $name) -> Self { + match t { $($name::$variant => $name_alias::$variant_alias),* } } + } - fn to_notmuch_t(self) -> $name { + impl Into<$name> for $name_alias { + fn into(self) -> $name { match self { $($name_alias::$variant_alias => $name::$variant),* } diff --git a/src/utils.rs b/src/utils.rs index ec5b5b3..b5acb66 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -8,13 +8,6 @@ use std::os::unix::ffi::OsStrExt; use libc; -pub trait NotmuchType { - type NotmuchT; - - fn from_notmuch_t(notmuch_t: Self::NotmuchT) -> Self; - fn to_notmuch_t(self) -> Self::NotmuchT; -} - pub trait ToCString { fn to_cstring(&self) -> Result<ffi::CString, ffi::NulError>; } |
