pub struct Download {
pub url: Url,
pub filename: String,
}Expand description
Represents a file to be downloaded.
Fields§
§url: UrlURL of the file to download.
filename: StringFile name used to save the file on disk.
Implementations§
Source§impl Download
impl Download
Sourcepub fn new(url: &Url, filename: &str) -> Self
pub fn new(url: &Url, filename: &str) -> Self
Creates a new Download.
When using the Download::try_from method, the file name is
automatically extracted from the URL.
§Example
The following calls are equivalent, minus some extra URL validations
performed by try_from:
use trauma::download::Download;
use reqwest::Url;
Download::try_from("https://example.com/file-0.1.2.zip")?;
Download::new(&Url::parse("https://example.com/file-0.1.2.zip")?, "file-0.1.2.zip");Sourcepub async fn is_resumable(
&self,
client: &ClientWithMiddleware,
) -> Result<bool, Error>
pub async fn is_resumable( &self, client: &ClientWithMiddleware, ) -> Result<bool, Error>
Check whether the download is resumable.
Sourcepub async fn content_length(
&self,
client: &ClientWithMiddleware,
) -> Result<Option<u64>, Error>
pub async fn content_length( &self, client: &ClientWithMiddleware, ) -> Result<Option<u64>, Error>
Retrieve the content_length of the download.
Returns None if the “content-length” header is missing or if its value is not a u64.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Download
impl RefUnwindSafe for Download
impl Send for Download
impl Sync for Download
impl Unpin for Download
impl UnsafeUnpin for Download
impl UnwindSafe for Download
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