diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2019-01-29 14:16:30 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2019-01-29 17:41:26 +0100 |
commit | e5f3ae121f39b46cbc0416acb4ba7049f40203d2 (patch) | |
tree | 96b9c4881271006f76e8e3f6ff90cfe2335e8d20 /openpgp-ffi/src/error.rs | |
parent | 442740975e41208c1cad300bc023ddedb04fc3a6 (diff) |
openpgp-ffi: Convert Error.
Diffstat (limited to 'openpgp-ffi/src/error.rs')
-rw-r--r-- | openpgp-ffi/src/error.rs | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/openpgp-ffi/src/error.rs b/openpgp-ffi/src/error.rs index f3df776c..3d4dd3ca 100644 --- a/openpgp-ffi/src/error.rs +++ b/openpgp-ffi/src/error.rs @@ -6,28 +6,28 @@ use libc::c_char; extern crate sequoia_openpgp as openpgp; -/// Frees an error. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn pgp_error_free(error: Option<&mut failure::Error>) { - ffi_free!(error) -} +/// Complex errors. +/// +/// This wraps [`failure::Error`]s. +/// +/// [`failure::Error`]: https://docs.rs/failure/0.1.5/failure/struct.Error.html +#[::ffi_wrapper_type(prefix = "pgp_", derive = "Display")] +pub struct Error(failure::Error); /// Returns the error message. /// /// The returned value must be freed with `free(3)`. #[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn pgp_error_string(error: *const failure::Error) - -> *mut c_char { - let error = ffi_param_ref!(error); - ffi_return_string!(&format!("{}", error)) +pub extern "system" fn pgp_error_string(error: *const Error) + -> *mut c_char { + ffi_return_string!(&format!("{}", error.ref_raw())) } /// Returns the error status code. #[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn pgp_error_status(error: *const failure::Error) +pub extern "system" fn pgp_error_status(error: *const Error) -> Status { - let error = ffi_param_ref!(error); - error.into() + error.ref_raw().into() } /// XXX: Reorder and name-space before release. |