X-Git-Url: https://code.octet-stream.net/hashgood/blobdiff_plain/e5c23eae73ae16d9fe574ed4b2ce015034035514..afd3bc461e6107350e584d20dc37926c62f76844:/src/main.rs?ds=inline diff --git a/src/main.rs b/src/main.rs index 2c7e189..f0fc474 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; @@ -41,11 +41,11 @@ impl Opt { fn get_paste(&self) -> bool { #[cfg(feature = "paste")] { - return self.paste; + self.paste } #[cfg(not(feature = "paste"))] { - return false; + false } } } @@ -75,8 +75,8 @@ impl Algorithm { pub enum VerificationSource { CommandArgument, Clipboard, - RawFile(PathBuf), - DigestsFile(PathBuf), + RawFile(String), + DigestsFile(String), } /// A complete standalone hash result @@ -87,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() { @@ -155,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)?;