playwright/imp/
download.rs

1use crate::imp::{artifact::Artifact, core::*, prelude::*};
2
3#[derive(Debug)]
4pub(crate) struct Download {
5    url: String,
6    suggested_filename: String,
7    artifact: Weak<Artifact>
8}
9
10impl Download {
11    pub(crate) fn new(artifact: Weak<Artifact>, url: String, suggested_filename: String) -> Self {
12        Self {
13            url,
14            suggested_filename,
15            artifact
16        }
17    }
18
19    pub(crate) fn url(&self) -> &str { &self.url }
20
21    pub(crate) fn suggested_filename(&self) -> &str { &self.suggested_filename }
22
23    pub(crate) async fn path(&self) -> ArcResult<Option<PathBuf>> {
24        upgrade(&self.artifact)?.path_after_finished().await
25    }
26
27    pub(crate) async fn delete(&self) -> ArcResult<()> { upgrade(&self.artifact)?.delete().await }
28
29    pub(crate) async fn save_as<P: AsRef<Path>>(&self, path: P) -> Result<(), Arc<Error>> {
30        upgrade(&self.artifact)?.save_as(path).await
31    }
32
33    pub(crate) async fn failure(&self) -> ArcResult<Option<String>> {
34        upgrade(&self.artifact)?.failure().await
35    }
36}