Function download_to_path

Source
pub async fn download_to_path<P>(
    client: &Client,
    url: &str,
    path: P,
) -> Result<()>
where P: AsRef<Path>,
Expand description

Using the given client, download the file at a url to a given path.

Note that this function will overwrite the file at the given path.

§Temporary Files

This will create a temporary “.part” file in the same directory while downloading. On failure, this file will try to be cleaned up. On success, this temporary file will be renamed to the actual file name. As a result, it may be assumed that the file created at the given path is the complete, non-erroneus download.

§Locking

During downloads, the temporary file is locked via advisory locking on platforms that support it. If locking is not supported, overwriting a pre-existing temporary file causes an error. Currently, Unix and Windows support advisory locking.