/// Download file and save it to the given
///
/// `uri`: Uri from where file is downloaded.
/// `client`: Https Client used to make request.
/// `destination`: Local path to save the downloaded package.
Download file and save it to the given
`uri`: Uri from where file is downloaded.
`client`: Https Client used to make request.
`destination`: Local path to save the downloaded package.
Download file and save it to the given ` uri ` : Uri from where file is downloaded . ` client ` : Https Client used to make request . ` destination ` : Local path to save the downloaded package .
async fn download_file_to_destination(
    uri: Uri,
    client: &HttpsClient,
    destination: PathBuf,
) -> Result<()> {
    let mut res = client.get(uri).await?;
    let status = res.status();
    if status != StatusCode::OK {
        ffx_bail!("Cannot download file to {}. Status is {}", destination.display(), status);
    }
    let mut output = async_fs::File::create(destination).await?;
    while let Some(next) = res.data().await {
        let chunk = next?;
        output.write_all(&chunk).await?;
    }
    Ok(())
}
async fn download_file_to_destination ( uri : Uri , client : & HttpsClient , destination : PathBuf , ) -> Result < ( ) > { let mut res = client . get ( uri ) . await ? ; let status = res . status ( ) ; if status != StatusCode :: OK { ffx_bail ! ( " " destination display ( ) status ) ; } let mut output = async_fs :: File :: create ( destination ) . await ? ; while let Some ( next ) = res . data ( ) . await { let chunk = next ? ; output . write_all ( & chunk ) . await ? ; } Ok ( ( ) ) }
Download file and save it to the given
`uri`: Uri from where file is downloaded.
Download file and save it to the given ` uri ` : Uri from where file is downloaded .
uri
Uri
client
&HttpsClient
destination
PathBuf