pub struct Downloader { /* private fields */ }
Implementations§
Source§impl Downloader
impl Downloader
pub fn get_client(&self) -> &Client
pub fn get_url(&self) -> String
pub fn get_len(&self) -> u64
pub fn filename(&self) -> &str
pub fn new_manual(url: &str, workers: u8, length: u64) -> Result<Self>
pub fn url_to_filename(url: &Url) -> Result<String>
Sourcepub fn progress_bar(&mut self) -> &mut Self
pub fn progress_bar(&mut self) -> &mut Self
Enable progress reporting
Sourcepub fn connect_progress(&mut self, pb: ProgressBar)
pub fn connect_progress(&mut self, pb: ProgressBar)
Connect the ProgressBar
indicatif::ProgressBar to the MultiProgress
indicatif::MultiProgress
Sourcepub fn bar_style(&self, style: ProgressStyle)
pub fn bar_style(&self, style: ProgressStyle)
Set the progress bar style
Sourcepub fn download(&self) -> Result<ChunkVec>
pub fn download(&self) -> Result<ChunkVec>
Download the file and verify if hash is set
§Example
use manic::threaded::Downloader;
use manic::ManicError;
let client = Downloader::new("https://crates.io", 5)?;
let result = client.download()?;
pub fn multi_download(self) -> Result<Downloaded>
Sourcepub fn download_and_save(&self, path: &str) -> Result<()>
pub fn download_and_save(&self, path: &str) -> Result<()>
Used to download, save to a file and verify against a SHA256 sum, returns an error if the connection fails or if the sum doesn’t match the one provided
§Arguments
path
- path to save the file to, if it’s a directory then the original filename is usedverify
- set true to verify the file against the hash
§Example
use manic::threaded::Downloader;
use manic::ManicError;
use manic::Hash;
fn main() -> Result<(), ManicError> {
let hash = Hash::new_sha256("039058c6f2c0cb492c533b0a4d14ef77cc0f78abccced5287d84a1a2011cfb81".to_string());
let client = Downloader::new("https://crates.io", 5)?.verify(hash);
client.download_and_save("~/Downloads")?;
Ok(())
}
Trait Implementations§
Source§impl Clone for Downloader
impl Clone for Downloader
Source§fn clone(&self) -> Downloader
fn clone(&self) -> Downloader
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for Downloader
impl !RefUnwindSafe for Downloader
impl Send for Downloader
impl Sync for Downloader
impl Unpin for Downloader
impl !UnwindSafe for Downloader
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more