3
3
use std:: fs:: remove_file;
4
4
use std:: path:: Path ;
5
5
6
+ use anyhow:: Context ;
6
7
#[ cfg( any(
7
8
not( feature = "curl-backend" ) ,
8
9
not( feature = "reqwest-rustls-tls" ) ,
9
10
not( feature = "reqwest-native-tls" )
10
11
) ) ]
11
12
use anyhow:: anyhow;
12
- use anyhow:: { Context , Result } ;
13
13
use sha2:: Sha256 ;
14
14
use thiserror:: Error ;
15
15
#[ cfg( any( feature = "reqwest-rustls-tls" , feature = "reqwest-native-tls" ) ) ]
@@ -28,7 +28,7 @@ pub(crate) async fn download_file(
28
28
hasher : Option < & mut Sha256 > ,
29
29
notify_handler : & dyn Fn ( Notification < ' _ > ) ,
30
30
process : & Process ,
31
- ) -> Result < ( ) > {
31
+ ) -> anyhow :: Result < ( ) > {
32
32
download_file_with_resume ( url, path, hasher, false , & notify_handler, process) . await
33
33
}
34
34
@@ -39,7 +39,7 @@ pub(crate) async fn download_file_with_resume(
39
39
resume_from_partial : bool ,
40
40
notify_handler : & dyn Fn ( Notification < ' _ > ) ,
41
41
process : & Process ,
42
- ) -> Result < ( ) > {
42
+ ) -> anyhow :: Result < ( ) > {
43
43
use crate :: download:: DownloadError as DEK ;
44
44
match download_file_ (
45
45
url,
@@ -87,7 +87,7 @@ async fn download_file_(
87
87
resume_from_partial : bool ,
88
88
notify_handler : & dyn Fn ( Notification < ' _ > ) ,
89
89
process : & Process ,
90
- ) -> Result < ( ) > {
90
+ ) -> anyhow :: Result < ( ) > {
91
91
#[ cfg( any( feature = "reqwest-rustls-tls" , feature = "reqwest-native-tls" ) ) ]
92
92
use crate :: download:: { Backend , Event , TlsBackend } ;
93
93
use sha2:: Digest ;
@@ -234,7 +234,7 @@ impl Backend {
234
234
path : & Path ,
235
235
resume_from_partial : bool ,
236
236
callback : Option < DownloadCallback < ' _ > > ,
237
- ) -> Result < ( ) > {
237
+ ) -> anyhow :: Result < ( ) > {
238
238
let Err ( err) = self
239
239
. download_impl ( url, path, resume_from_partial, callback)
240
240
. await
@@ -258,7 +258,7 @@ impl Backend {
258
258
path : & Path ,
259
259
resume_from_partial : bool ,
260
260
callback : Option < DownloadCallback < ' _ > > ,
261
- ) -> Result < ( ) > {
261
+ ) -> anyhow :: Result < ( ) > {
262
262
use std:: cell:: RefCell ;
263
263
use std:: fs:: OpenOptions ;
264
264
use std:: io:: { Read , Seek , SeekFrom , Write } ;
@@ -350,7 +350,7 @@ impl Backend {
350
350
url : & Url ,
351
351
resume_from : u64 ,
352
352
callback : DownloadCallback < ' _ > ,
353
- ) -> Result < ( ) > {
353
+ ) -> anyhow :: Result < ( ) > {
354
354
match self {
355
355
#[ cfg( feature = "curl-backend" ) ]
356
356
Self :: Curl => curl:: download ( url, resume_from, callback) ,
@@ -376,7 +376,7 @@ impl TlsBackend {
376
376
url : & Url ,
377
377
resume_from : u64 ,
378
378
callback : DownloadCallback < ' _ > ,
379
- ) -> Result < ( ) > {
379
+ ) -> anyhow :: Result < ( ) > {
380
380
let client = match self {
381
381
#[ cfg( feature = "reqwest-rustls-tls" ) ]
382
382
Self :: Rustls => & reqwest_be:: CLIENT_RUSTLS_TLS ,
@@ -397,7 +397,7 @@ enum Event<'a> {
397
397
DownloadDataReceived ( & ' a [ u8 ] ) ,
398
398
}
399
399
400
- type DownloadCallback < ' a > = & ' a dyn Fn ( Event < ' _ > ) -> Result < ( ) > ;
400
+ type DownloadCallback < ' a > = & ' a dyn Fn ( Event < ' _ > ) -> anyhow :: Result < ( ) > ;
401
401
402
402
/// Download via libcurl; encrypt with the native (or OpenSSl) TLS
403
403
/// stack via libcurl
@@ -522,7 +522,7 @@ mod reqwest_be {
522
522
use std:: sync:: LazyLock ;
523
523
use std:: time:: Duration ;
524
524
525
- use anyhow:: { Context , Result , anyhow} ;
525
+ use anyhow:: { Context , anyhow} ;
526
526
use reqwest:: { Client , ClientBuilder , Proxy , Response , header} ;
527
527
#[ cfg( feature = "reqwest-rustls-tls" ) ]
528
528
use rustls:: crypto:: aws_lc_rs;
@@ -536,9 +536,9 @@ mod reqwest_be {
536
536
pub ( super ) async fn download (
537
537
url : & Url ,
538
538
resume_from : u64 ,
539
- callback : & dyn Fn ( Event < ' _ > ) -> Result < ( ) > ,
539
+ callback : & dyn Fn ( Event < ' _ > ) -> anyhow :: Result < ( ) > ,
540
540
client : & Client ,
541
- ) -> Result < ( ) > {
541
+ ) -> anyhow :: Result < ( ) > {
542
542
// Short-circuit reqwest for the "file:" URL scheme
543
543
if download_from_file_url ( url, resume_from, callback) ? {
544
544
return Ok ( ( ) ) ;
@@ -641,8 +641,8 @@ mod reqwest_be {
641
641
fn download_from_file_url (
642
642
url : & Url ,
643
643
resume_from : u64 ,
644
- callback : & dyn Fn ( Event < ' _ > ) -> Result < ( ) > ,
645
- ) -> Result < bool > {
644
+ callback : & dyn Fn ( Event < ' _ > ) -> anyhow :: Result < ( ) > ,
645
+ ) -> anyhow :: Result < bool > {
646
646
use std:: fs;
647
647
648
648
// The file scheme is mostly for use by tests to mock the dist server
0 commit comments