pub struct RequestBuilder<'a> { /* private fields */ }
Expand description
A builder to configure download request.
See custom configuration for an example.
Implementations§
Source§impl<'a> RequestBuilder<'a>
impl<'a> RequestBuilder<'a>
Sourcepub fn hash<D: DynDigest + 'static>(self, expected: &str, digest: D) -> Self
pub fn hash<D: DynDigest + 'static>(self, expected: &str, digest: D) -> Self
Sets expected file hash and digest used to calculate it.
Hash is given in hexadecimal, uppercase or lowercase.
§Examples
use ml_downloader::Downloader;
use sha2::{Digest, Sha256};
let mut downloader = Downloader::new()?;
let bytes = downloader
.get("https://example.com/")
.hash("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", Sha256::new())
.send()?;
Sourcepub fn send(self) -> Result<Bytes, Error>
pub fn send(self) -> Result<Bytes, Error>
Creates download request and sends it to target URL, with retries.
- Sleeps before starting download if needed.
- Number of retries and the delays inbetween them is configured with
DownloaderBuilder::retry_delays
.
See simple usage and RequestBuilder::hash
for examples.
Auto Trait Implementations§
impl<'a> !Freeze for RequestBuilder<'a>
impl<'a> !RefUnwindSafe for RequestBuilder<'a>
impl<'a> !Send for RequestBuilder<'a>
impl<'a> !Sync for RequestBuilder<'a>
impl<'a> Unpin for RequestBuilder<'a>
impl<'a> !UnwindSafe for RequestBuilder<'a>
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