pub async fn pull<F>(
        &self,
        path: ArtifactoryPath,
        dest: &Path,
        mut progress: F,
    ) -> Result<(), Error>
    where
        F: FnMut(DownloadProgress),
    {
        let url = format!("{}/artifactory/{}", self.origin, path.0);
        let url = Url::parse(&url).unwrap();

        let mut dest = std::fs::File::create(dest)?;

        let mut res = reqwest::get(url).await?;

        let expected_bytes_downloaded = res.content_length().unwrap_or(0);
        let mut bytes_downloaded = 0;
        while let Some(chunk) = res.chunk().await? {
            bytes_downloaded += chunk.as_ref().len() as u64;
            dest.write_all(chunk.as_ref())?;
            let status = DownloadProgress {
                expected_bytes_downloaded,
                bytes_downloaded,
            };
            progress(status);
        }

        Ok(())
    }
/// Fetch a remote artifact.
///
/// An optional progress closure can be provided to get updates on the
/// transfer.
Fetch a remote artifact.
An optional progress closure can be provided to get updates on the
transfer.
Fetch a remote artifact . An optional progress closure can be provided to get updates on the transfer .
pub async fn pull<F>(
        &self,
        path: ArtifactoryPath,
        dest: &Path,
        mut progress: F,
    ) -> Result<(), Error>
    where
        F: FnMut(DownloadProgress),
    {
        let url = format!("{}/artifactory/{}", self.origin, path.0);
        let url = Url::parse(&url).unwrap();
        let mut dest = std::fs::File::create(dest)?;
        let mut res = reqwest::get(url).await?;
        let expected_bytes_downloaded = res.content_length().unwrap_or(0);
        let mut bytes_downloaded = 0;
        while let Some(chunk) = res.chunk().await? {
            bytes_downloaded += chunk.as_ref().len() as u64;
            dest.write_all(chunk.as_ref())?;
            let status = DownloadProgress {
                expected_bytes_downloaded,
                bytes_downloaded,
            };
            progress(status);
        }
        Ok(())
    }
pub async fn pull < F > ( & self , path : ArtifactoryPath , dest : & Path , mut progress : F , ) -> Result < ( ) , Error > where F : FnMut ( DownloadProgress ) , { let url = format ! ( " " self origin path 0 ) ; let url = Url :: parse ( & url ) . unwrap ( ) ; let mut dest = std :: fs :: File :: create ( dest ) ? ; let mut res = reqwest :: get ( url ) . await ? ; let expected_bytes_downloaded = res . content_length ( ) . unwrap_or ( 0 ) ; let mut bytes_downloaded = 0 ; while let Some ( chunk ) = res . chunk ( ) . await ? { bytes_downloaded += chunk . as_ref ( ) . len ( ) as u64 ; dest . write_all ( chunk . as_ref ( ) ) ? ; let status = DownloadProgress { expected_bytes_downloaded , bytes_downloaded , } ; progress ( status ) ; } Ok ( ( ) ) }
Fetch a remote artifact.
Fetch a remote artifact .
&self
path
ArtifactoryPath
dest
&Path
progress
F
&self
path
ArtifactoryPath
dest
&Path
progress
F