diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2020-03-09 11:42:45 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2020-03-09 18:09:50 +0100 |
commit | 391a4b92c977cd64dfd131f3e29b0bc8d756d064 (patch) | |
tree | b5b96ff935853cef9ee22e01890c248a791e724e /openpgp-ffi/src/serialize.rs | |
parent | 58d662c6d37dd1b0dccd4d0ce30290b8ede408e9 (diff) |
Switch from failure to anyhow.
- Use the anyhow crate instead of failure to implement the dynamic
side of our error handling. anyhow::Error derefs to dyn
std::error::Error, allowing better interoperability with other
stdlib-based error handling libraries.
- Fixes #444.
Diffstat (limited to 'openpgp-ffi/src/serialize.rs')
-rw-r--r-- | openpgp-ffi/src/serialize.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/openpgp-ffi/src/serialize.rs b/openpgp-ffi/src/serialize.rs index 1f16b7d5..dbbb537c 100644 --- a/openpgp-ffi/src/serialize.rs +++ b/openpgp-ffi/src/serialize.rs @@ -63,7 +63,7 @@ pub extern "C" fn pgp_writer_stack_write let buf = unsafe { slice::from_raw_parts(buf, len as usize) }; - ffi_try_or!(writer.write(buf).map_err(|e| ::failure::Error::from(e)), -1) as ssize_t + ffi_try_or!(writer.write(buf).map_err(|e| ::anyhow::Error::from(e)), -1) as ssize_t } /// Writes up to `len` bytes of `buf` into `writer`. @@ -84,7 +84,7 @@ pub extern "C" fn pgp_writer_stack_write_all let buf = unsafe { slice::from_raw_parts(buf, len as usize) }; - ffi_try_status!(writer.write_all(buf).map_err(|e| ::failure::Error::from(e))) + ffi_try_status!(writer.write_all(buf).map_err(|e| ::anyhow::Error::from(e))) } /// Finalizes this writer, returning the underlying writer. @@ -168,7 +168,7 @@ pub extern "C" fn pgp_signer_new let mut signer = Signer::new(*inner, ffi_try!(signers.pop().ok_or_else(|| { - failure::format_err!("signers is empty") + anyhow::anyhow!("signers is empty") }))); for s in signers { signer = signer.add_signer(s); @@ -205,7 +205,7 @@ pub extern "C" fn pgp_signer_new_detached let mut signer = Signer::new(*inner, ffi_try!(signers.pop().ok_or_else(|| { - failure::format_err!("signers is empty") + anyhow::anyhow!("signers is empty") }))); for s in signers { signer = signer.add_signer(s); @@ -386,7 +386,7 @@ pub extern "C" fn pgp_encryptor_new<'a> Some(aead_algo.into()) }; if passwords_.len() + recipients_.len() == 0 { - ffi_try!(Err(failure::format_err!( + ffi_try!(Err(anyhow::anyhow!( "Neither recipient nor password given"))); } |