Function checkasum::check_file_path

source ·
pub fn check_file_path(
    method: &HashAlgorithm,
    path: &PathBuf,
    expected: &str
) -> Result<ChecksumResult, ChecksumResult>
Expand description

Checks file at given path, comparing against an expected checksum digest, using a particular matching hashing method.

§Examples

use std::env;
use std::path::PathBuf;
use checkasum::check_file_path;
use checkasum::hashing::HashAlgorithm::SHA256;

let sample_file_path: PathBuf = [
            env::var("CARGO_MANIFEST_DIR").unwrap(),
            "tests".to_string(),
            "fixtures".to_string(),
            "sample.txt".to_string()
        ].iter().collect();

let _result = check_file_path(&SHA256, &sample_file_path, &"test_digest".to_string());