pub struct Downloader { /* private fields */ }
Expand description
Simple blocking downloader.
See crate index for examples.
Implementations§
Source§impl Downloader
impl Downloader
Sourcepub fn builder() -> DownloaderBuilder
pub fn builder() -> DownloaderBuilder
Creates DownloaderBuilder
to configure Downloader
.
This is same as DownloaderBuilder::new
.
See custom configuration for an example.
Sourcepub fn get<U: IntoUrl>(&mut self, url: U) -> RequestBuilder<'_>
pub fn get<U: IntoUrl>(&mut self, url: U) -> RequestBuilder<'_>
Begins building a request to download file from given url
.
See simple usage and RequestBuilder::hash
for examples.
§Errors
If given url
is invalid then RequestBuilder::send
will fail.
Sourcepub fn new() -> Result<Self, Error>
pub fn new() -> Result<Self, Error>
Creates new Downloader
with default configuration.
Sourcepub fn sleep_until_ready(&mut self)
pub fn sleep_until_ready(&mut self)
Sleeps until ready for next download.
After this the next RequestBuilder::send
will start
download immediately without sleep.
See DownloaderBuilder::interval
.
§Examples
use ml_downloader::Downloader;
let mut downloader = Downloader::builder()
.interval(1.0, 1.0)
.build()?;
println!("First download");
let bytes1 = downloader.get("https://example.com/first").send()?;
downloader.sleep_until_ready();
println!("Second download");
let bytes2 = downloader.get("https://example.com/second").send()?;
Auto 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