switch from failure to anyhow

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller
2020-04-17 14:11:25 +02:00
parent 404d78c41e
commit f7d4e4b506
116 changed files with 129 additions and 129 deletions

View File

@ -2,7 +2,7 @@ use std::future::Future;
use std::pin::Pin;
use std::sync::{Arc, Mutex};
use failure::*;
use anyhow::{format_err, Error};
use futures::future::{FutureExt, TryFutureExt};
use tokio::sync::oneshot;

View File

@ -9,7 +9,7 @@ use std::panic::UnwindSafe;
use std::pin::Pin;
use std::task::{Context, Poll};
use failure::*;
use anyhow::{bail, format_err, Error};
use proxmox::tools::io::{ReadExt, WriteExt};

View File

@ -1,4 +1,4 @@
use failure::*;
use anyhow::{Error};
use chrono::{TimeZone, Local};
use std::io::Write;
@ -10,7 +10,7 @@ use std::io::Write;
/// #### Example:
/// ```
/// #[macro_use] extern crate proxmox_backup;
/// # use failure::*;
/// # use anyhow::{bail, format_err, Error};
/// use proxmox_backup::tools::FileLogger;
///
/// # std::fs::remove_file("test.log");

View File

@ -1,4 +1,4 @@
use failure::*;
use anyhow::{Error};
use serde_json::Value;
use chrono::{Local, TimeZone};

View File

@ -4,7 +4,7 @@ use std::borrow::{Borrow, BorrowMut};
use std::ops::{Deref, DerefMut};
use std::os::unix::io::{AsRawFd, RawFd};
use failure::*;
use anyhow::{format_err, Error};
use nix::dir;
use nix::dir::Dir;
use regex::Regex;
@ -73,7 +73,7 @@ impl ReadDirEntry {
}
// Since Tied<T, U> implements Deref to U, a Tied<Dir, Iterator> already implements Iterator.
// This is simply a wrapper with a shorter type name mapping nix::Error to failure::Error.
// This is simply a wrapper with a shorter type name mapping nix::Error to anyhow::Error.
/// Wrapper over a pair of `nix::dir::Dir` and `nix::dir::Iter`, returned by `read_subdir()`.
pub struct ReadDir {
iter: Tied<Dir, dyn Iterator<Item = nix::Result<dir::Entry>> + Send>,

View File

@ -14,7 +14,7 @@ pub trait Cacher<K, V> {
/// Whenever a cache miss occurs, the fetch method provides a corresponding value.
/// If no value can be obtained for the given key, None is returned, the cache is
/// not updated in that case.
fn fetch(&mut self, key: K) -> Result<Option<V>, failure::Error>;
fn fetch(&mut self, key: K) -> Result<Option<V>, anyhow::Error>;
}
/// Node of the doubly linked list storing key and value
@ -46,11 +46,11 @@ impl<K, V> CacheNode<K, V> {
/// # Examples:
/// ```
/// # use self::proxmox_backup::tools::lru_cache::{Cacher, LruCache};
/// # fn main() -> Result<(), failure::Error> {
/// # fn main() -> Result<(), anyhow::Error> {
/// struct LruCacher {};
///
/// impl Cacher<u64, u64> for LruCacher {
/// fn fetch(&mut self, key: u64) -> Result<Option<u64>, failure::Error> {
/// fn fetch(&mut self, key: u64) -> Result<Option<u64>, anyhow::Error> {
/// Ok(Some(key))
/// }
/// }
@ -189,7 +189,7 @@ impl<K: std::cmp::Eq + std::hash::Hash + Copy, V> LruCache<K, V> {
/// value.
/// If fetch returns a value, it is inserted as the most recently used entry
/// in the cache.
pub fn access<'a>(&'a mut self, key: K, cacher: &mut dyn Cacher<K, V>) -> Result<Option<&'a mut V>, failure::Error> {
pub fn access<'a>(&'a mut self, key: K, cacher: &mut dyn Cacher<K, V>) -> Result<Option<&'a mut V>, anyhow::Error> {
match self.map.entry(key) {
Entry::Occupied(mut o) => {
// Cache hit, birng node to front of list

View File

@ -7,7 +7,7 @@
//! the timestamp for the oldest open lock with
//! `oldest_shared_lock()`.
use failure::*;
use anyhow::{bail, Error};
use std::sync::{Arc, Mutex};
use std::os::unix::io::AsRawFd;

View File

@ -1,7 +1,7 @@
use std::io::Write;
use std::sync::mpsc::SyncSender;
use failure::*;
use anyhow::{Error};
/// Wrapper around SyncSender, which implements Write
///

View File

@ -1,6 +1,6 @@
//! Generate and verify Authentification tickets
use failure::*;
use anyhow::{bail, Error};
use base64;
use openssl::pkey::{PKey, Public, Private};

View File

@ -61,7 +61,7 @@ impl<T> Stream for StdChannelStream<T> {
mod test {
use std::io;
use failure::Error;
use anyhow::Error;
use futures::stream::TryStreamExt;
#[test]