async fn write_blob_to_file(
    file_path: &Path,
    mut blob: Blob,
    progress: ProgressBar,
) -> Result<(), failure::Error> {
    let mut file = File::create(&file_path)
        .await
        .context(format!("could not create {:?}", file_path))?;

    while let Some(data) = blob
        .chunk()
        .await
        .context(format!("error while downloading {:?}", file_path))?
    {
        let bytes_written = file
            .write(data.as_ref())
            .await
            .context(format!("error while writing to {:?}", file_path))?;
        progress.inc(bytes_written as u64);
    }
    progress.finish();
    Ok(())
}
/// Writes a blob to disk as it's downloaded
Writes a blob to disk as it's downloaded
Writes a blob to disk as it ' s downloaded
async fn write_blob_to_file(
    file_path: &Path,
    mut blob: Blob,
    progress: ProgressBar,
) -> Result<(), failure::Error> {
    let mut file = File::create(&file_path)
        .await
        .context(format!("could not create {:?}", file_path))?;
    while let Some(data) = blob
        .chunk()
        .await
        .context(format!("error while downloading {:?}", file_path))?
    {
        let bytes_written = file
            .write(data.as_ref())
            .await
            .context(format!("error while writing to {:?}", file_path))?;
        progress.inc(bytes_written as u64);
    }
    progress.finish();
    Ok(())
}
async fn write_blob_to_file ( file_path : & Path , mut blob : Blob , progress : ProgressBar , ) -> Result < ( ) , failure :: Error > { let mut file = File :: create ( & file_path ) . await . context ( format ! ( " " file_path ) ) ? ; while let Some ( data ) = blob . chunk ( ) . await . context ( format ! ( " " file_path ) ) ? { let bytes_written = file . write ( data . as_ref ( ) ) . await . context ( format ! ( " " file_path ) ) ? ; progress . inc ( bytes_written as u64 ) ; } progress . finish ( ) ; Ok ( ( ) ) }
Writes a blob to disk as it's downloaded
Writes a blob to disk as it ' s downloaded
file_path
&Path
blob
Blob
progress
ProgressBar
file_path
&Path
blob
Blob
progress
ProgressBar