pub struct Download { /* private fields */ }Expand description
A file download initiated by the page.
Produced by Page::on_download. The download lands in
a per-page temp directory; call path or
save_as to retrieve it.
Implementations§
Source§impl Download
impl Download
Sourcepub fn page(&self) -> Page
pub fn page(&self) -> Page
The page that owns this download.
Cheap clone — Page is Arc-backed, so the returned handle shares the
page’s state with the caller.
Sourcepub fn suggested_filename(&self) -> &str
pub fn suggested_filename(&self) -> &str
The filename suggested by the server (suggestedFilename).
Sourcepub fn failure(&self) -> Option<&str>
pub fn failure(&self) -> Option<&str>
A failure reason, if the download was canceled. None otherwise.
Sourcepub async fn path(&self) -> Result<Option<PathBuf>>
pub async fn path(&self) -> Result<Option<PathBuf>>
The on-disk path of the completed download, or None if it failed.
Waits for the download to finish; once Completed, polls briefly for
the file to appear (Chrome renames the .crdownload temp on finish).
Sourcepub async fn save_as(&self, to: impl AsRef<Path>) -> Result<PathBuf>
pub async fn save_as(&self, to: impl AsRef<Path>) -> Result<PathBuf>
Copy the downloaded file to to and return the destination path.
Sourcepub async fn delete(&self) -> Result<()>
pub async fn delete(&self) -> Result<()>
Best-effort remove the downloaded file from the temp directory.
Sourcepub async fn create_read_stream(&self) -> Result<File>
pub async fn create_read_stream(&self) -> Result<File>
Open the downloaded file as a read stream.