Add a from_url method to ZipDownloader struct.

This commit is contained in:
Bas Wiel, van de 2024-04-30 18:29:47 +02:00
parent a32dfcb983
commit 5398bc36c4
1 changed files with 9 additions and 0 deletions

View File

@ -32,6 +32,15 @@ impl ZipDownloader {
}
}
/// Construct a new ZipDownloader from a URL. Combines the construction and initial download
/// of the ZIP file in a single function call. The struct can then be used to operate on its
/// contents.
pub fn from_url(url: &str, message: Option<&str>) -> Result<Self, std::io::Error> {
let mut downloader = Self::new();
downloader.download_zip(url, message)?;
Ok(downloader)
}
pub fn get_files(&self) -> &Vec<DownloadedFile> {
&self.files
}