[−][src]Struct manic::Downloader
Implementations
impl Downloader
[src]
pub async fn new(url: &str, workers: u8) -> Result<Self>
[src]
Create a new downloader
Arguments
url
- URL of the fileworkers
- amount of concurrent tasks
Examples
use manic::Downloader; // If only one TLS feature is enabled let downloader = Downloader::new("https://crates.io", 5).await?;
pub fn get_filename(url: &Url) -> Result<String>
[src]
Get filename from the url, returns an error if the url contains no filename
Arguments
url
- &str with the url
Example
use manic::Downloader; use manic::Error; let url = manic::Url::parse("http://test.rs/test.zip")?; let name = Downloader::get_filename(&url)?; assert_eq!("test.zip", name);
pub fn progress_bar(&mut self) -> &mut Self
[src]
Enable progress reporting
pub fn bar_style(&self, style: ProgressStyle)
[src]
Set the progress bar style
pub fn verify(&mut self, hash: Hash) -> Self
[src]
pub async fn download(&self) -> Result<Vec<u8>>
[src]
Download the file
Example
use manic::Downloader; use manic::Error; let client = Downloader::new("https://crates.io", 5).await?; let result = client.download().await?;
pub async fn download_and_verify(&self) -> Result<Vec<u8>>
[src]
Download and verify the file
Example
use manic::Downloader; use manic::Error; let client = Downloader::new("https://crates.io", 5).await?; let result = client.download_and_verify().await?;
pub async fn download_and_save(&self, path: &str, verify: bool) -> Result<()>
[src]
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::Downloader; use manic::Error; use manic::Hash; #[tokio::main] async fn main() -> Result<(), Error> { let hash = Hash::SHA256("039058c6f2c0cb492c533b0a4d14ef77cc0f78abccced5287d84a1a2011cfb81".to_string()); let client = Downloader::new("https://crates.io", 5).await?.verify(hash); client.download_and_save("~/Downloads", true).await?; Ok(()) }
Trait Implementations
impl Clone for Downloader
[src]
pub fn clone(&self) -> Downloader
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for Downloader
[src]
Auto Trait Implementations
impl !RefUnwindSafe for Downloader
[src]
impl Send for Downloader
[src]
impl Sync for Downloader
[src]
impl Unpin for Downloader
[src]
impl !UnwindSafe for Downloader
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> WithSubscriber for T
[src]
pub fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
[src]
S: Into<Dispatch>,