Skip to main content

load_batch

Function load_batch 

Source
pub fn load_batch(path: &Path) -> Result<Vec<Target>>
Expand description

Load hash targets from a batch file.

Each non-empty, non-comment line in the file must contain a hexadecimal hash followed by an optional filename:

<hex-hash> [filename]

If the filename is present it is stored in Target::name and is later used by search to limit hashing to files with the same basename.

§Examples

let path = PathBuf::from("targets.txt");
fs::write(&path, "d2d2d2d2 example.txt\n# comment line\n")?;
let targets = hash_hunter::load_batch(&path)?;
assert_eq!(targets.len(), 1);

§Errors

Returns an error if the file cannot be read, if a line is malformed, or if a hash cannot be parsed by parse_hex. Line numbers are included in formatting errors to aid debugging.