summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2020-05-12 21:59:21 +0200
committerMatthias Beyer <mail@beyermatthias.de>2020-05-12 22:14:20 +0200
commit68d9fb8e9a88489e66cb0678900186ee71afcee6 (patch)
treed67757d36b1de0e3334c240186a960531759c2af
parentccef8f81f3905f5545db97b9bd720570e3381289 (diff)
Switch to anyhow
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--Cargo.toml3
-rw-r--r--src/app.rs2
-rw-r--r--src/cli.rs2
-rw-r--r--src/main.rs5
-rw-r--r--src/repository/client.rs18
-rw-r--r--src/repository/repository.rs3
-rw-r--r--src/types/block.rs2
-rw-r--r--src/types/content.rs2
-rw-r--r--src/types/payload.rs2
9 files changed, 19 insertions, 20 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 7e3e944..de1266a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -17,7 +17,7 @@ edition = "2018"
[dependencies]
is-match = "0.1"
-failure = "0.1"
+anyhow = "1"
futures = "0.3"
ipfs-api = { version = "0.7", features = ["actix"], default-features = false }
serde = "1"
@@ -42,3 +42,4 @@ handlebars = "3"
actix-rt = "1"
actix-web = "2"
port_check = "0.1"
+failure = "0.1"
diff --git a/src/app.rs b/src/app.rs
index d06e1d2..cc07c6e 100644
--- a/src/app.rs
+++ b/src/app.rs
@@ -1,6 +1,6 @@
use std::collections::BTreeMap;
-use failure::Error;
+use anyhow::Error;
use futures::Stream;
use futures::stream;
diff --git a/src/cli.rs b/src/cli.rs
index dddff76..815c065 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -1,7 +1,7 @@
use std::path::PathBuf;
use structopt::StructOpt;
-use failure::Error;
+use anyhow::Error;
#[derive(Debug, StructOpt)]
#[structopt(name = "example", about = "An example of StructOpt usage.")]
diff --git a/src/main.rs b/src/main.rs
index 0eeb683..a3588f3 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -18,8 +18,9 @@ extern crate handlebars;
extern crate web_view;
extern crate actix_rt;
extern crate actix_web;
+extern crate failure;
-#[macro_use] extern crate failure;
+#[macro_use] extern crate anyhow;
#[macro_use] extern crate is_match;
#[macro_use] extern crate serde_derive;
#[macro_use] extern crate log;
@@ -75,7 +76,7 @@ fn main() -> Result<()> {
let config: Configuration = {
let configfile = xdg::BaseDirectories::with_prefix("distrox")?
.find_config_file(&config_file_name)
- .ok_or_else(|| err_msg("No configuration found"))?;
+ .ok_or_else(|| anyhow!("No configuration found"))?;
let configstr = ::std::fs::read_to_string(&configfile)?;
::toml::from_str(&configstr)?
diff --git a/src/repository/client.rs b/src/repository/client.rs
index 62a6826..841625d 100644
--- a/src/repository/client.rs
+++ b/src/repository/client.rs
@@ -3,14 +3,13 @@ use std::sync::Arc;
use std::ops::Deref;
use ipfs_api::IpfsClient;
-use failure::Error;
-use failure::err_msg;
-use failure::AsFail;
+use anyhow::Error;
use futures::future::Future;
use futures::future::FutureExt;
use futures::stream::Stream;
use futures::stream::StreamExt;
use futures::stream::TryStreamExt;
+use failure::Fail;
use serde_json::from_str as serde_json_from_str;
use serde_json::to_string as serde_json_to_str;
@@ -37,7 +36,7 @@ impl ClientFassade {
IpfsClient::new(host, port)
.map(Arc::new)
.map(|c| ClientFassade(c))
- .map_err(|e| Error::from(e.as_fail()))
+ .map_err(|e| Error::from(e.compat()))
}
pub async fn get_raw_bytes<H: AsRef<IPFSHash>>(&self, hash: H) -> Result<Vec<u8>, Error> {
@@ -47,7 +46,7 @@ impl ClientFassade {
.cat(hash.as_ref())
.map_ok(|b| b.to_vec())
.try_concat()
- .map(|r| r.map_err(|e| Error::from(e.as_fail())))
+ .map(|r| r.map_err(|e| anyhow!("UNIMPLEMENTED!()")))
.await
}
@@ -58,7 +57,7 @@ impl ClientFassade {
.add(Cursor::new(data))
.await
.map(|res| IPFSHash::from(res.hash))
- .map_err(|e| Error::from(e.as_fail()))
+ .map_err(|e| anyhow!("UNIMPLEMENTED!()"))
}
pub async fn publish(&self, key: &str, hash: &str) -> Result<IPNSHash, Error> {
@@ -68,7 +67,7 @@ impl ClientFassade {
.name_publish(hash, false, None, None, Some(key))
.await
.map(|res| IPNSHash::from(res.value))
- .map_err(|e| Error::from(e.as_fail()))
+ .map_err(|e| anyhow!("UNIMPLEMENTED!()"))
}
pub async fn resolve(&self, ipns: IPNSHash) -> Result<IPFSHash, Error> {
@@ -77,7 +76,7 @@ impl ClientFassade {
.name_resolve(Some(&ipns), true, false)
.await
.map(|res| IPFSHash::from(res.path))
- .map_err(|e| Error::from(e.as_fail()))
+ .map_err(|e| anyhow!("UNIMPLEMENTED!()"))
}
}
@@ -109,8 +108,7 @@ impl TypedClientFassade {
.and_then(|data| {
debug!("Got data, building object: {:?}", data);
- serde_json::from_slice(&data)
- .map_err(|e| Error::from(e.as_fail()))
+ serde_json::from_slice(&data).map_err(|e| Error::from(e.compat()))
})
}
diff --git a/src/repository/repository.rs b/src/repository/repository.rs
index 6b97d45..a63c2d6 100644
--- a/src/repository/repository.rs
+++ b/src/repository/repository.rs
@@ -3,8 +3,7 @@ use std::sync::Arc;
use std::ops::Deref;
use ipfs_api::IpfsClient;
-use failure::Error;
-use failure::err_msg;
+use anyhow::Error;
use futures::future::Future;
use futures::stream::Stream;
diff --git a/src/types/block.rs b/src/types/block.rs
index 15661f6..1927d55 100644
--- a/src/types/block.rs
+++ b/src/types/block.rs
@@ -5,7 +5,7 @@ use crate::types::payload::*;
use crate::types::content::LoadedContent;
use crate::repository::repository::Repository;
-use failure::Error;
+use anyhow::Error;
#[derive(Serialize, Deserialize, Debug)]
pub struct Block {
diff --git a/src/types/content.rs b/src/types/content.rs
index aea2dbc..4812abd 100644
--- a/src/types/content.rs
+++ b/src/types/content.rs
@@ -1,6 +1,6 @@
use std::collections::BTreeMap;
-use failure::Error;
+use anyhow::Error;
use crate::types::util::IPFSHash;
use crate::types::util::IPNSHash;
diff --git a/src/types/payload.rs b/src/types/payload.rs
index 8a7de71..2d85c22 100644
--- a/src/types/payload.rs
+++ b/src/types/payload.rs
@@ -1,6 +1,6 @@
use std::collections::BTreeMap;
-use failure::Error;
+use anyhow::Error;
use crate::types::util::IPFSHash;
use crate::types::util::IPNSHash;