Function fetch_data::hash_download
source · [−]pub fn hash_download<U: AsRef<str>, P: AsRef<Path>>(
url: U,
path: P
) -> Result<String, FetchDataError>Expand description
Download a file from a URL and compute its hash.
Example
use fetch_data::hash_download;
use temp_testdir::TempDir;
// Create a temporary local directory.
let temp_dir = TempDir::default();
let path = temp_dir.join("small.fam");
// Download a file and compute its hash.
let hash = hash_download(
"https://raw.githubusercontent.com/CarlKCarlK/fetch-data/main/tests/data/small.fam",
&path,
)?;
assert!(hash.eq("36e0086c0353ff336d0533330dbacb12c75e37dc3cba174313635b98dfe86ed2"));