summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2020-03-09 11:42:45 +0100
committerJustus Winter <justus@sequoia-pgp.org>2020-03-09 18:09:50 +0100
commit391a4b92c977cd64dfd131f3e29b0bc8d756d064 (patch)
treeb5b96ff935853cef9ee22e01890c248a791e724e /net
parent58d662c6d37dd1b0dccd4d0ce30290b8ede408e9 (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 'net')
-rw-r--r--net/Cargo.toml2
-rw-r--r--net/src/lib.rs7
-rw-r--r--net/src/wkd.rs8
3 files changed, 8 insertions, 9 deletions
diff --git a/net/Cargo.toml b/net/Cargo.toml
index f817a6b2..86a4404c 100644
--- a/net/Cargo.toml
+++ b/net/Cargo.toml
@@ -24,7 +24,7 @@ maintenance = { status = "actively-developed" }
sequoia-openpgp = { path = "../openpgp", version = "0.15", default-features = false }
sequoia-core = { path = "../core", version = "0.15" }
-failure = "0.1.2"
+anyhow = "1"
futures = "0.1"
http = "0.1.5"
hyper = "0.12"
diff --git a/net/src/lib.rs b/net/src/lib.rs
index b7ed9cdc..15f6ddb0 100644
--- a/net/src/lib.rs
+++ b/net/src/lib.rs
@@ -38,7 +38,6 @@
extern crate sequoia_openpgp as openpgp;
extern crate sequoia_core;
-extern crate failure;
extern crate futures;
extern crate http;
extern crate hyper;
@@ -157,7 +156,7 @@ impl KeyServer {
/// Retrieves the key with the given `keyid`.
pub fn get(&mut self, keyid: &KeyID)
- -> Box<dyn Future<Item=Cert, Error=failure::Error> + 'static> {
+ -> Box<dyn Future<Item=Cert, Error=anyhow::Error> + 'static> {
let keyid_want = keyid.clone();
let uri = self.uri.join(
&format!("pks/lookup?op=get&options=mr&search=0x{}",
@@ -205,7 +204,7 @@ impl KeyServer {
/// Sends the given key to the server.
pub fn send(&mut self, key: &Cert)
- -> Box<dyn Future<Item=(), Error=failure::Error> + 'static> {
+ -> Box<dyn Future<Item=(), Error=anyhow::Error> + 'static> {
use crate::openpgp::armor::{Writer, Kind};
let uri =
@@ -291,7 +290,7 @@ pub(crate) fn url2uri(uri: Url) -> hyper::Uri {
}
/// Results for sequoia-net.
-pub type Result<T> = ::std::result::Result<T, failure::Error>;
+pub type Result<T> = ::std::result::Result<T, anyhow::Error>;
#[derive(thiserror::Error, Debug)]
/// Errors returned from the network routines.
diff --git a/net/src/wkd.rs b/net/src/wkd.rs
index 4c9e0283..526ca14b 100644
--- a/net/src/wkd.rs
+++ b/net/src/wkd.rs
@@ -22,7 +22,7 @@ use std::fmt;
use std::fs;
use std::path::{Path, PathBuf};
-use failure::ResultExt;
+use anyhow::Context;
use futures::{future, Future, Stream};
use hyper::{Uri, Client};
use hyper_tls::HttpsConnector;
@@ -291,7 +291,7 @@ fn parse_body<S: AsRef<str>>(body: &[u8], email_address: S)
// XXX: Maybe the direct method should be tried on other errors too.
// https://mailarchive.ietf.org/arch/msg/openpgp/6TxZc2dQFLKXtS0Hzmrk963EteE
pub fn get<S: AsRef<str>>(email_address: S)
- -> impl Future<Item=Vec<Cert>, Error=failure::Error> {
+ -> impl Future<Item=Vec<Cert>, Error=anyhow::Error> {
let email = email_address.as_ref().to_string();
future::lazy(move || -> Result<_> {
// First, prepare URIs and client.
@@ -407,14 +407,14 @@ impl KeyRing {
impl crate::openpgp::serialize::Serialize for KeyRing {}
impl Marshal for KeyRing {
- fn serialize(&self, o: &mut dyn std::io::Write) -> Result<()> {
+ fn serialize(&self, o: &mut dyn std::io::Write) -> openpgp::Result<()> {
for cert in self.0.values() {
cert.serialize(o)?;
}
Ok(())
}
- fn export(&self, o: &mut dyn std::io::Write) -> Result<()> {
+ fn export(&self, o: &mut dyn std::io::Write) -> openpgp::Result<()> {
for cert in self.0.values() {
cert.export(o)?;
}