X-Git-Url: https://code.octet-stream.net/hashgood/blobdiff_plain/0252a4d67a68e71c811a6f7ec8057b616e65bca7..12939f1c8ec8ecba887c4ea7dca40337ad6832d9:/src/main.rs?ds=sidebyside diff --git a/src/main.rs b/src/main.rs index f0bf09c..fd965da 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,5 @@ use std::error::Error; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use std::process; use structopt::StructOpt; @@ -71,11 +71,12 @@ impl Algorithm { } /// The method by which one or more hashes were supplied to verify the calculated digest +#[derive(Debug, PartialEq)] pub enum VerificationSource { CommandArgument, Clipboard, - RawFile(PathBuf), - DigestsFile(PathBuf), + RawFile(String), + DigestsFile(String), } /// A complete standalone hash result @@ -86,7 +87,7 @@ pub struct Hash { } impl Hash { - pub fn new(alg: Algorithm, bytes: Vec, path: &PathBuf) -> Self { + pub fn new(alg: Algorithm, bytes: Vec, path: &Path) -> Self { // Taking the filename component should always work? // If not, just fall back to the full path let filename = match path.file_name() { @@ -102,6 +103,7 @@ impl Hash { } /// A possible hash to match against. The algorithm is assumed. +#[derive(Debug, PartialEq)] pub struct CandidateHash { bytes: Vec, filename: Option, @@ -109,6 +111,7 @@ pub struct CandidateHash { /// A list of candidate hashes that our input could potentially match. At this point it is /// assumed that we will be verifying a digest of a particular, single algorithm. +#[derive(Debug, PartialEq)] pub struct CandidateHashes { alg: Algorithm, hashes: Vec, @@ -152,7 +155,7 @@ fn main() { fn hashgood() -> Result<(), Box> { let opt = get_verified_options()?; let candidates = verify::get_candidate_hashes(&opt)?; - let input = calculate::get_input_reader(&opt.input)?; + let input = calculate::get_input_reader(opt.input.as_path())?; if let Some(c) = candidates { // If we have a candidate hash of a particular type, use that specific algorithm let hashes = calculate::create_digests(&[c.alg], input)?;