Skip to content

Commit 25a7bb7

Browse files
committed
refactor(client-cli): move HttpDownloader trait in a dedicated interface.rs sub module
1 parent efb7743 commit 25a7bb7

File tree

2 files changed

+23
-20
lines changed

2 files changed

+23
-20
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
use std::path::{Path, PathBuf};
2+
3+
use async_trait::async_trait;
4+
use reqwest::Url;
5+
6+
use mithril_client::MithrilResult;
7+
8+
/// Trait for downloading a file over HTTP from a URL,
9+
/// saving it to a target directory with the given filename.
10+
///
11+
/// Returns the path to the downloaded file.
12+
#[cfg_attr(test, mockall::automock)]
13+
#[async_trait]
14+
pub trait HttpDownloader {
15+
async fn download_file(
16+
&self,
17+
url: Url,
18+
download_dir: &Path,
19+
filename: &str,
20+
) -> MithrilResult<PathBuf>;
21+
}
Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,5 @@
1+
mod interface;
12
mod reqwest_http_downloader;
23

4+
pub use interface::*;
35
pub use reqwest_http_downloader::*;
4-
5-
use async_trait::async_trait;
6-
use mithril_client::MithrilResult;
7-
use reqwest::Url;
8-
use std::path::{Path, PathBuf};
9-
10-
/// Trait for downloading a file over HTTP from a URL,
11-
/// saving it to a target directory with the given filename.
12-
///
13-
/// Returns the path to the downloaded file.
14-
#[cfg_attr(test, mockall::automock)]
15-
#[async_trait]
16-
pub trait HttpDownloader {
17-
async fn download_file(
18-
&self,
19-
url: Url,
20-
download_dir: &Path,
21-
filename: &str,
22-
) -> MithrilResult<PathBuf>;
23-
}

0 commit comments

Comments
 (0)