pub async fn download(&self, url: &str, tmpfile: &mut TmpFile) -> Result<()> {
        let file = tmpfile.handle()?;

        // Start the GET and attempt to get a content-length
        let mut resp   = self.get(&url).await?;
        let total_size = resp.content_length();

        // Setup the progress display
        let pb = self.progress_bar(total_size);

        // Start downloading chunks.
        while let Some(chunk) = resp.chunk().await? {
            // Write the chunk to the output file.
            file.write_all(&chunk)?;

            // Poke the progress indicator
            if total_size.is_some() {
                pb.inc(chunk.len() as u64);
            }
            else {
                pb.tick();
            }
        }

        pb.finish_with_message(PROGRESS_FINISHED_MSG);

        Ok(())
    }
// Download from the given URL to the output file.
Download from the given URL to the output file.
Download from the given URL to the output file .
pub async fn download(&self, url: &str, tmpfile: &mut TmpFile) -> Result<()> {
        let file = tmpfile.handle()?;
        // Start the GET and attempt to get a content-length
        let mut resp   = self.get(&url).await?;
        let total_size = resp.content_length();
        // Setup the progress display
        let pb = self.progress_bar(total_size);
        // Start downloading chunks.
        while let Some(chunk) = resp.chunk().await? {
            // Write the chunk to the output file.
            file.write_all(&chunk)?;
            // Poke the progress indicator
            if total_size.is_some() {
                pb.inc(chunk.len() as u64);
            }
            else {
                pb.tick();
            }
        }
        pb.finish_with_message(PROGRESS_FINISHED_MSG);
        Ok(())
    }
pub async fn download ( & self , url : & str , tmpfile : & mut TmpFile ) -> Result < ( ) > { let file = tmpfile . handle ( ) ? ; // Start the GET and attempt to get a content-length let mut resp = self . get ( & url ) . await ? ; let total_size = resp . content_length ( ) ; // Setup the progress display let pb = self . progress_bar ( total_size ) ; // Start downloading chunks. while let Some ( chunk ) = resp . chunk ( ) . await ? { // Write the chunk to the output file. file . write_all ( & chunk ) ? ; // Poke the progress indicator if total_size . is_some ( ) { pb . inc ( chunk . len ( ) as u64 ) ; } else { pb . tick ( ) ; } } pb . finish_with_message ( PROGRESS_FINISHED_MSG ) ; Ok ( ( ) ) }
Download from the given URL to the output file.
Download from the given URL to the output file .
&self
url
&str
tmpfile
&mut TmpFile
&self
url
&str
tmpfile
&mut TmpFile