]> git.proxmox.com Git - pxar.git/commitdiff
ditch anyhow crate in examples/tests
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Mon, 17 May 2021 09:46:50 +0000 (11:46 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Mon, 17 May 2021 09:46:53 +0000 (11:46 +0200)
mostly to shutup our current buildbot tests

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Cargo.toml
examples/pxarcmd.rs
tests/simple/fs.rs
tests/simple/main.rs

index c35ba0cafc28a4ef4d29feefd7300e1ccc4057a1..f586e5de5809e74e0a17be41159edbc9e423630a 100644 (file)
@@ -19,7 +19,6 @@ required-features = [ "async-example" ]
 [[example]]
 name = "pxarcmd"
 path = "examples/pxarcmd.rs"
-required-features = [ "anyhow" ]
 
 [[example]]
 name = "mk-format-hashes"
@@ -32,7 +31,7 @@ doc = false
 name = "simple"
 path = "tests/simple/main.rs"
 test = true
-required-features = [ "anyhow", "test-harness" ]
+required-features = [ "test-harness" ]
 
 [[test]]
 name = "compat"
@@ -45,7 +44,6 @@ bitflags = "1.2.1"
 endian_trait = { version = "0.6", features = ["arrays"] }
 siphasher = "0.3"
 
-anyhow = { version = "1.0", optional = true }
 tokio = { version = "1.0", optional = true, default-features = false }
 
 [target.'cfg(target_os = "linux")'.dependencies]
@@ -59,7 +57,6 @@ tokio-fs = [ "tokio-io", "tokio/fs" ]
 full = [ "tokio-fs"]
 
 async-example = [
-    "anyhow",
     "tokio-io",
     "tokio-fs",
     "tokio/rt-multi-thread",
index 85858000d87bccb7a473659b90a4558bd69166ed..e0c779d577880658bb31234670b29e286282ddb7 100644 (file)
@@ -5,12 +5,24 @@ use std::os::linux::fs::MetadataExt;
 use std::os::unix::ffi::OsStrExt;
 use std::path::{Path, PathBuf};
 
-use anyhow::{bail, format_err, Error};
-
 use pxar::accessor::Accessor;
 use pxar::encoder::{Encoder, LinkOffset, SeqWrite};
 use pxar::Metadata;
 
+macro_rules! format_err {
+    ($($msg:tt)+) => {
+        std::io::Error::new(std::io::ErrorKind::Other, format!($($msg)+))
+    };
+}
+
+macro_rules! bail {
+    ($($msg:tt)+) => {{
+        return Err(format_err!($($msg)+).into());
+    }};
+}
+
+type Error = Box<dyn std::error::Error + Send + Sync + 'static>;
+
 fn main() -> Result<(), Error> {
     let mut args = std::env::args_os();
     let _ = args.next();
index 7b1f5956264cca92662cb90debe7aae893467d24..9a89c4de254d55e8c828c1b7cdd299d130661073 100644 (file)
@@ -2,8 +2,6 @@ use std::collections::HashMap;
 use std::io::Read;
 use std::path::{Path, PathBuf};
 
-use anyhow::{bail, format_err, Error};
-
 use pxar::decoder::sync as decoder;
 use pxar::decoder::SeqRead;
 use pxar::encoder::sync as encoder;
@@ -13,6 +11,8 @@ use pxar::format::{mode, Device};
 use pxar::EntryKind as PxarEntryKind;
 use pxar::Metadata;
 
+use crate::Error;
+
 /// Hardlink information we use while encoding pxar archives.
 pub struct HardlinkInfo {
     link: LinkOffset,
index f15a0f5a5aa2b8d1d2d1ddc444a445fd568c188b..676322d5480c2f81edc3e32a2bacc64c0d341b73 100644 (file)
@@ -1,14 +1,26 @@
 use std::io::Read;
 use std::path::Path;
 
-use anyhow::{bail, Error};
-
 use pxar::accessor::sync as accessor;
 use pxar::decoder::sync as decoder;
 use pxar::encoder::sync as encoder;
 use pxar::encoder::SeqWrite;
 use pxar::EntryKind as PxarEntryKind;
 
+macro_rules! format_err {
+    ($($msg:tt)+) => {
+        std::io::Error::new(std::io::ErrorKind::Other, format!($($msg)+))
+    };
+}
+
+macro_rules! bail {
+    ($($msg:tt)+) => {{
+        return Err(format_err!($($msg)+).into());
+    }};
+}
+
+pub type Error = Box<dyn std::error::Error + Send + Sync + 'static>;
+
 mod fs;
 
 fn encode_directory<T: SeqWrite>(