Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a49e5cb

Browse filesBrowse files
committed
chore: remove anyhow and human_bytes dependencies
1 parent 0a4979d commit a49e5cb
Copy full SHA for a49e5cb

File tree

Expand file treeCollapse file tree

15 files changed

+54
-96
lines changed
Filter options
Expand file treeCollapse file tree

15 files changed

+54
-96
lines changed

‎Cargo.lock

Copy file name to clipboardExpand all lines: Cargo.lock
-8Lines changed: 0 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml

Copy file name to clipboardExpand all lines: Cargo.toml
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ futures-util = "0.3.30"
3636
hex = "0.4.3"
3737
home = "0.5.11"
3838
http = "1.1.0"
39-
human_bytes = { version = "0.4.3", default-features = false }
4039
indicatif = "0.17.8"
4140
indoc = "2.0.5"
4241
liblzma = "0.3.4"

‎postgresql_archive/Cargo.toml

Copy file name to clipboardExpand all lines: postgresql_archive/Cargo.toml
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,11 @@ rust-version.workspace = true
1111
version.workspace = true
1212

1313
[dependencies]
14-
anyhow = { workspace = true }
1514
async-trait = { workspace = true }
1615
flate2 = { workspace = true }
1716
futures-util = { workspace = true }
1817
hex = { workspace = true }
1918
http = { workspace = true }
20-
human_bytes = { workspace = true, default-features = false }
2119
liblzma = { workspace = true }
2220
md-5 = { workspace = true, optional = true }
2321
num-format = { workspace = true }
@@ -43,6 +41,7 @@ url = { workspace = true }
4341
zip = { workspace = true }
4442

4543
[dev-dependencies]
44+
anyhow = { workspace = true }
4645
criterion = { workspace = true }
4746
hex = { workspace = true }
4847
test-log = { workspace = true }

‎postgresql_archive/src/error.rs

Copy file name to clipboardExpand all lines: postgresql_archive/src/error.rs
+13-27Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ pub enum Error {
1717
#[error("version '{0}' is invalid")]
1818
InvalidVersion(String),
1919
/// IO error
20-
#[error(transparent)]
21-
IoError(anyhow::Error),
20+
#[error("{0}")]
21+
IoError(String),
2222
/// Parse error
23-
#[error(transparent)]
24-
ParseError(anyhow::Error),
23+
#[error("{0}")]
24+
ParseError(String),
2525
/// Poisoned lock
2626
#[error("poisoned lock '{0}'")]
2727
PoisonedLock(String),
@@ -51,70 +51,63 @@ pub enum Error {
5151
/// Converts a [`regex::Error`] into an [`ParseError`](Error::ParseError)
5252
impl From<regex::Error> for Error {
5353
fn from(error: regex::Error) -> Self {
54-
Error::ParseError(error.into())
54+
Error::ParseError(error.to_string())
5555
}
5656
}
5757

5858
/// Converts a [`reqwest::Error`] into an [`IoError`](Error::IoError)
5959
impl From<reqwest::Error> for Error {
6060
fn from(error: reqwest::Error) -> Self {
61-
Error::IoError(error.into())
61+
Error::IoError(error.to_string())
6262
}
6363
}
6464

6565
/// Converts a [`reqwest_middleware::Error`] into an [`IoError`](Error::IoError)
6666
impl From<reqwest_middleware::Error> for Error {
6767
fn from(error: reqwest_middleware::Error) -> Self {
68-
Error::IoError(error.into())
68+
Error::IoError(error.to_string())
6969
}
7070
}
7171

7272
/// Converts a [`std::io::Error`] into an [`IoError`](Error::IoError)
7373
impl From<std::io::Error> for Error {
7474
fn from(error: std::io::Error) -> Self {
75-
Error::IoError(error.into())
75+
Error::IoError(error.to_string())
7676
}
7777
}
7878

7979
/// Converts a [`std::time::SystemTimeError`] into an [`IoError`](Error::IoError)
8080
impl From<std::time::SystemTimeError> for Error {
8181
fn from(error: std::time::SystemTimeError) -> Self {
82-
Error::IoError(error.into())
82+
Error::IoError(error.to_string())
8383
}
8484
}
8585

8686
/// Converts a [`std::num::ParseIntError`] into an [`ParseError`](Error::ParseError)
8787
impl From<std::num::ParseIntError> for Error {
8888
fn from(error: std::num::ParseIntError) -> Self {
89-
Error::ParseError(error.into())
89+
Error::ParseError(error.to_string())
9090
}
9191
}
9292

9393
/// Converts a [`semver::Error`] into an [`ParseError`](Error::ParseError)
9494
impl From<semver::Error> for Error {
9595
fn from(error: semver::Error) -> Self {
96-
Error::IoError(error.into())
96+
Error::IoError(error.to_string())
9797
}
9898
}
9999

100100
/// Converts a [`std::path::StripPrefixError`] into an [`ParseError`](Error::ParseError)
101101
impl From<std::path::StripPrefixError> for Error {
102102
fn from(error: std::path::StripPrefixError) -> Self {
103-
Error::ParseError(error.into())
104-
}
105-
}
106-
107-
/// Converts a [`anyhow::Error`] into an [`Unexpected`](Error::Unexpected)
108-
impl From<anyhow::Error> for Error {
109-
fn from(error: anyhow::Error) -> Self {
110-
Error::Unexpected(error.to_string())
103+
Error::ParseError(error.to_string())
111104
}
112105
}
113106

114107
/// Converts a [`url::ParseError`] into an [`ParseError`](Error::ParseError)
115108
impl From<url::ParseError> for Error {
116109
fn from(error: url::ParseError) -> Self {
117-
Error::ParseError(error.into())
110+
Error::ParseError(error.to_string())
118111
}
119112
}
120113

@@ -200,13 +193,6 @@ mod test {
200193
);
201194
}
202195

203-
#[test]
204-
fn test_from_anyhow_error() {
205-
let anyhow_error = anyhow::Error::msg("test");
206-
let error = Error::from(anyhow_error);
207-
assert_eq!(error.to_string(), "test");
208-
}
209-
210196
#[test]
211197
fn test_from_url_parse_error() {
212198
let parse_error = url::ParseError::EmptyHost;

‎postgresql_archive/src/extractor/tar_gz_extractor.rs

Copy file name to clipboardExpand all lines: postgresql_archive/src/extractor/tar_gz_extractor.rs
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use crate::extractor::ExtractDirectories;
22
use crate::Error::Unexpected;
33
use crate::Result;
44
use flate2::bufread::GzDecoder;
5-
use human_bytes::human_bytes;
65
use num_format::{Locale, ToFormattedString};
76
use std::fs::{create_dir_all, File};
87
use std::io::{copy, BufReader, Cursor};
@@ -14,7 +13,6 @@ use tracing::{debug, instrument, warn};
1413
///
1514
/// # Errors
1615
/// Returns an error if the extraction fails.
17-
#[expect(clippy::cast_precision_loss)]
1816
#[instrument(skip(bytes))]
1917
pub fn extract(bytes: &Vec<u8>, extract_directories: ExtractDirectories) -> Result<Vec<PathBuf>> {
2018
let mut files = Vec::new();
@@ -74,7 +72,7 @@ pub fn extract(bytes: &Vec<u8>, extract_directories: ExtractDirectories) -> Resu
7472
debug!(
7573
"Extracted {} files totalling {}",
7674
number_of_files.to_formatted_string(&Locale::en),
77-
human_bytes(extracted_bytes as f64)
75+
extracted_bytes,
7876
);
7977

8078
Ok(files)

‎postgresql_archive/src/extractor/tar_xz_extractor.rs

Copy file name to clipboardExpand all lines: postgresql_archive/src/extractor/tar_xz_extractor.rs
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use crate::extractor::ExtractDirectories;
22
use crate::Error::Unexpected;
33
use crate::Result;
4-
use human_bytes::human_bytes;
54
use liblzma::bufread::XzDecoder;
65
use num_format::{Locale, ToFormattedString};
76
use std::fs::{create_dir_all, File};
@@ -14,7 +13,6 @@ use tracing::{debug, instrument, warn};
1413
///
1514
/// # Errors
1615
/// Returns an error if the extraction fails.
17-
#[expect(clippy::cast_precision_loss)]
1816
#[instrument(skip(bytes))]
1917
pub fn extract(bytes: &Vec<u8>, extract_directories: ExtractDirectories) -> Result<Vec<PathBuf>> {
2018
let mut files = Vec::new();
@@ -76,7 +74,7 @@ pub fn extract(bytes: &Vec<u8>, extract_directories: ExtractDirectories) -> Resu
7674
debug!(
7775
"Extracted {} files totalling {}",
7876
number_of_files.to_formatted_string(&Locale::en),
79-
human_bytes(extracted_bytes as f64)
77+
extracted_bytes,
8078
);
8179

8280
Ok(files)

‎postgresql_archive/src/extractor/zip_extractor.rs

Copy file name to clipboardExpand all lines: postgresql_archive/src/extractor/zip_extractor.rs
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crate::extractor::ExtractDirectories;
22
use crate::Result;
3-
use human_bytes::human_bytes;
43
use num_format::{Locale, ToFormattedString};
54
use std::fs::create_dir_all;
65
use std::io::Cursor;
@@ -13,7 +12,6 @@ use zip::ZipArchive;
1312
///
1413
/// # Errors
1514
/// Returns an error if the extraction fails.
16-
#[expect(clippy::cast_precision_loss)]
1715
#[instrument(skip(bytes))]
1816
pub fn extract(bytes: &Vec<u8>, extract_directories: ExtractDirectories) -> Result<Vec<PathBuf>> {
1917
let mut files = Vec::new();
@@ -47,7 +45,7 @@ pub fn extract(bytes: &Vec<u8>, extract_directories: ExtractDirectories) -> Resu
4745
debug!(
4846
"Extracted {} files totalling {}",
4947
number_of_files.to_formatted_string(&Locale::en),
50-
human_bytes(extracted_bytes as f64)
48+
extracted_bytes,
5149
);
5250

5351
Ok(files)

‎postgresql_archive/src/repository/github/repository.rs

Copy file name to clipboardExpand all lines: postgresql_archive/src/repository/github/repository.rs
+2-4Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use crate::{hasher, matcher, Result};
99
use async_trait::async_trait;
1010
use futures_util::StreamExt;
1111
use http::{header, Extensions};
12-
use human_bytes::human_bytes;
1312
use regex::Regex;
1413
use reqwest::{Request, Response};
1514
use reqwest_middleware::{ClientBuilder, ClientWithMiddleware, Middleware, Next};
@@ -216,7 +215,6 @@ impl Repository for GitHub {
216215
}
217216

218217
#[instrument]
219-
#[expect(clippy::cast_precision_loss)]
220218
async fn get_archive(&self, version_req: &VersionReq) -> Result<Archive> {
221219
let release = self.get_release(version_req).await?;
222220
let version = Self::get_version_from_tag_name(release.tag_name.as_str())?;
@@ -239,7 +237,7 @@ impl Repository for GitHub {
239237
debug!(
240238
"Archive {} downloaded: {}",
241239
asset.browser_download_url,
242-
human_bytes(bytes.len() as f64)
240+
bytes.len(),
243241
);
244242

245243
if let Some(asset_hash) = asset_hash {
@@ -264,7 +262,7 @@ impl Repository for GitHub {
264262
debug!(
265263
"Archive hash {} downloaded: {}",
266264
asset_hash.browser_download_url,
267-
human_bytes(text.len() as f64)
265+
text.len(),
268266
);
269267

270268
if archive_hash != hash {

‎postgresql_archive/src/repository/maven/repository.rs

Copy file name to clipboardExpand all lines: postgresql_archive/src/repository/maven/repository.rs
+3-11Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use crate::{hasher, Result};
66
use async_trait::async_trait;
77
use futures_util::StreamExt;
88
use http::{header, Extensions};
9-
use human_bytes::human_bytes;
109
use reqwest::{Request, Response};
1110
use reqwest_middleware::{ClientBuilder, ClientWithMiddleware, Middleware, Next};
1211
use reqwest_retry::policies::ExponentialBackoff;
@@ -62,7 +61,7 @@ impl Maven {
6261
let response = request.send().await?.error_for_status()?;
6362
let text = response.text().await?;
6463
let metadata: Metadata =
65-
quick_xml::de::from_str(&text).map_err(|error| ParseError(error.into()))?;
64+
quick_xml::de::from_str(&text).map_err(|error| ParseError(error.to_string()))?;
6665
let artifact = metadata.artifact_id;
6766
let mut result = None;
6867
for version in &metadata.versioning.versions.version {
@@ -103,7 +102,6 @@ impl Repository for Maven {
103102
}
104103

105104
#[instrument]
106-
#[expect(clippy::cast_precision_loss)]
107105
async fn get_archive(&self, version_req: &VersionReq) -> Result<Archive> {
108106
let (artifact, version) = self.get_artifact(version_req).await?;
109107
let archive_name = format!("{artifact}-{version}.jar");
@@ -129,10 +127,7 @@ impl Repository for Maven {
129127
let request = client.get(&archive_hash_url);
130128
let response = request.send().await?.error_for_status()?;
131129
let hash = response.text().await?;
132-
debug!(
133-
"Archive hash {archive_hash_url} downloaded: {}",
134-
human_bytes(hash.len() as f64)
135-
);
130+
debug!("Archive hash {archive_hash_url} downloaded: {}", hash.len(),);
136131

137132
debug!("Downloading archive {archive_url}");
138133
let request = client.get(&archive_url);
@@ -146,10 +141,7 @@ impl Repository for Maven {
146141
bytes.write_all(&chunk?)?;
147142
span.pb_set_position(bytes.len() as u64);
148143
}
149-
debug!(
150-
"Archive {archive_url} downloaded: {}",
151-
human_bytes(bytes.len() as f64)
152-
);
144+
debug!("Archive {archive_url} downloaded: {}", bytes.len(),);
153145

154146
let archive_hash = hasher_fn(&bytes)?;
155147
if archive_hash != hash {

‎postgresql_commands/Cargo.toml

Copy file name to clipboardExpand all lines: postgresql_commands/Cargo.toml
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ version.workspace = true
1313
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1414

1515
[dependencies]
16-
anyhow = { workspace = true }
1716
thiserror = { workspace = true }
1817
tokio = { workspace = true, features = ["full"], optional = true }
1918
tracing = { workspace = true, features = ["log"] }

‎postgresql_commands/src/error.rs

Copy file name to clipboardExpand all lines: postgresql_commands/src/error.rs
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,25 @@ pub enum Error {
88
#[error("Command error: stdout={stdout}; stderr={stderr}")]
99
CommandError { stdout: String, stderr: String },
1010
/// Error when IO operations fail
11-
#[error(transparent)]
12-
IoError(anyhow::Error),
11+
#[error("{0}")]
12+
IoError(String),
1313
/// Error when a command fails to execute before the timeout is reached
14-
#[error(transparent)]
15-
TimeoutError(anyhow::Error),
14+
#[error("{0}")]
15+
TimeoutError(String),
1616
}
1717

1818
/// Convert [standard IO errors](std::io::Error) to a [embedded errors](Error::IoError)
1919
impl From<std::io::Error> for Error {
2020
fn from(error: std::io::Error) -> Self {
21-
Error::IoError(error.into())
21+
Error::IoError(error.to_string())
2222
}
2323
}
2424

2525
#[cfg(feature = "tokio")]
2626
/// Convert [elapsed time errors](tokio::time::error::Elapsed) to [embedded errors](Error::TimeoutError)
2727
impl From<tokio::time::error::Elapsed> for Error {
2828
fn from(error: tokio::time::error::Elapsed) -> Self {
29-
Error::TimeoutError(error.into())
29+
Error::TimeoutError(error.to_string())
3030
}
3131
}
3232

‎postgresql_embedded/Cargo.toml

Copy file name to clipboardExpand all lines: postgresql_embedded/Cargo.toml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ tokio = { workspace = true, features = ["full"] }
1919
url = { workspace = true }
2020

2121
[dependencies]
22-
anyhow = { workspace = true }
2322
home = { workspace = true }
2423
postgresql_archive = { path = "../postgresql_archive", version = "0.17.4", default-features = false }
2524
postgresql_commands = { path = "../postgresql_commands", version = "0.17.4" }
@@ -33,6 +32,7 @@ tracing = { workspace = true, features = ["log"] }
3332
url = { workspace = true }
3433

3534
[dev-dependencies]
35+
anyhow = { workspace = true }
3636
criterion = { workspace = true }
3737
test-log = { workspace = true }
3838
tokio = { workspace = true, features = ["full"] }

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.