Skip to content

Commit f405664

Browse files
committed
Avoid importing anyhow::Result alias
1 parent 3200634 commit f405664

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/download/mod.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
use std::fs::remove_file;
44
use std::path::Path;
55

6+
use anyhow::Context;
67
#[cfg(any(
78
not(feature = "curl-backend"),
89
not(feature = "reqwest-rustls-tls"),
910
not(feature = "reqwest-native-tls")
1011
))]
1112
use anyhow::anyhow;
12-
use anyhow::{Context, Result};
1313
use sha2::Sha256;
1414
use thiserror::Error;
1515
#[cfg(any(feature = "reqwest-rustls-tls", feature = "reqwest-native-tls"))]
@@ -28,7 +28,7 @@ pub(crate) async fn download_file(
2828
hasher: Option<&mut Sha256>,
2929
notify_handler: &dyn Fn(Notification<'_>),
3030
process: &Process,
31-
) -> Result<()> {
31+
) -> anyhow::Result<()> {
3232
download_file_with_resume(url, path, hasher, false, &notify_handler, process).await
3333
}
3434

@@ -39,7 +39,7 @@ pub(crate) async fn download_file_with_resume(
3939
resume_from_partial: bool,
4040
notify_handler: &dyn Fn(Notification<'_>),
4141
process: &Process,
42-
) -> Result<()> {
42+
) -> anyhow::Result<()> {
4343
use crate::download::DownloadError as DEK;
4444
match download_file_(
4545
url,
@@ -87,7 +87,7 @@ async fn download_file_(
8787
resume_from_partial: bool,
8888
notify_handler: &dyn Fn(Notification<'_>),
8989
process: &Process,
90-
) -> Result<()> {
90+
) -> anyhow::Result<()> {
9191
#[cfg(any(feature = "reqwest-rustls-tls", feature = "reqwest-native-tls"))]
9292
use crate::download::{Backend, Event, TlsBackend};
9393
use sha2::Digest;
@@ -234,7 +234,7 @@ impl Backend {
234234
path: &Path,
235235
resume_from_partial: bool,
236236
callback: Option<DownloadCallback<'_>>,
237-
) -> Result<()> {
237+
) -> anyhow::Result<()> {
238238
let Err(err) = self
239239
.download_impl(url, path, resume_from_partial, callback)
240240
.await
@@ -258,7 +258,7 @@ impl Backend {
258258
path: &Path,
259259
resume_from_partial: bool,
260260
callback: Option<DownloadCallback<'_>>,
261-
) -> Result<()> {
261+
) -> anyhow::Result<()> {
262262
use std::cell::RefCell;
263263
use std::fs::OpenOptions;
264264
use std::io::{Read, Seek, SeekFrom, Write};
@@ -350,7 +350,7 @@ impl Backend {
350350
url: &Url,
351351
resume_from: u64,
352352
callback: DownloadCallback<'_>,
353-
) -> Result<()> {
353+
) -> anyhow::Result<()> {
354354
match self {
355355
#[cfg(feature = "curl-backend")]
356356
Self::Curl => curl::download(url, resume_from, callback),
@@ -376,7 +376,7 @@ impl TlsBackend {
376376
url: &Url,
377377
resume_from: u64,
378378
callback: DownloadCallback<'_>,
379-
) -> Result<()> {
379+
) -> anyhow::Result<()> {
380380
let client = match self {
381381
#[cfg(feature = "reqwest-rustls-tls")]
382382
Self::Rustls => &reqwest_be::CLIENT_RUSTLS_TLS,
@@ -397,7 +397,7 @@ enum Event<'a> {
397397
DownloadDataReceived(&'a [u8]),
398398
}
399399

400-
type DownloadCallback<'a> = &'a dyn Fn(Event<'_>) -> Result<()>;
400+
type DownloadCallback<'a> = &'a dyn Fn(Event<'_>) -> anyhow::Result<()>;
401401

402402
/// Download via libcurl; encrypt with the native (or OpenSSl) TLS
403403
/// stack via libcurl
@@ -522,7 +522,7 @@ mod reqwest_be {
522522
use std::sync::LazyLock;
523523
use std::time::Duration;
524524

525-
use anyhow::{Context, Result, anyhow};
525+
use anyhow::{Context, anyhow};
526526
use reqwest::{Client, ClientBuilder, Proxy, Response, header};
527527
#[cfg(feature = "reqwest-rustls-tls")]
528528
use rustls::crypto::aws_lc_rs;
@@ -536,9 +536,9 @@ mod reqwest_be {
536536
pub(super) async fn download(
537537
url: &Url,
538538
resume_from: u64,
539-
callback: &dyn Fn(Event<'_>) -> Result<()>,
539+
callback: &dyn Fn(Event<'_>) -> anyhow::Result<()>,
540540
client: &Client,
541-
) -> Result<()> {
541+
) -> anyhow::Result<()> {
542542
// Short-circuit reqwest for the "file:" URL scheme
543543
if download_from_file_url(url, resume_from, callback)? {
544544
return Ok(());
@@ -641,8 +641,8 @@ mod reqwest_be {
641641
fn download_from_file_url(
642642
url: &Url,
643643
resume_from: u64,
644-
callback: &dyn Fn(Event<'_>) -> Result<()>,
645-
) -> Result<bool> {
644+
callback: &dyn Fn(Event<'_>) -> anyhow::Result<()>,
645+
) -> anyhow::Result<bool> {
646646
use std::fs;
647647

648648
// The file scheme is mostly for use by tests to mock the dist server

0 commit comments

Comments
 (0)