pub struct Hash { /* private fields */ }Implementations§
Source§impl Hash
impl Hash
pub fn new(bits: Vec<Vec<bool>>) -> Result<Hash, ImageHashError>
Sourcepub fn to_hex(&self) -> String
pub fn to_hex(&self) -> String
Examples found in repository?
examples/squint-cli.rs (line 32)
21fn main() -> ExitCode {
22 let args: Vec<String> = env::args().collect();
23 if args.len() != 4 {
24 eprintln!("usage: squint-cli <algo> <size> <path>");
25 return ExitCode::from(2);
26 }
27 let algo = args[1].as_str();
28 let size: usize = args[2].parse().unwrap_or(8);
29 let path = &args[3];
30
31 let result = match algo {
32 "phash" => phash(path, size).map(|h| h.to_hex()),
33 "phash_simple" => phash_simple(path, size).map(|h| h.to_hex()),
34 "dhash" => dhash(path, size).map(|h| h.to_hex()),
35 "dhash_vertical" => dhash_vertical(path, size).map(|h| h.to_hex()),
36 "average_hash" => average_hash(path, size).map(|h| h.to_hex()),
37 "whash_haar" => whash_haar(path, size).map(|h| h.to_hex()),
38 "whash_db4" => whash_db4(path, size).map(|h| h.to_hex()),
39 "whash_db4_robust" => whash_db4_robust(path, size).map(|h| h.to_hex()),
40 "colorhash" => colorhash(path, size).map(|h| h.to_hex()),
41 "crop_resistant_hash" => crop_resistant_hash(path, None).map(|mh| mh.to_hex()),
42 _ => {
43 eprintln!("unknown algo: {}", algo);
44 return ExitCode::from(2);
45 }
46 };
47
48 match result {
49 Ok(hex) => {
50 println!("{}", hex);
51 ExitCode::from(0)
52 }
53 Err(e) => {
54 eprintln!("error: {}", e);
55 ExitCode::from(1)
56 }
57 }
58}pub fn subtract(&self, other: &Hash) -> Result<usize, ImageHashError>
pub fn bit_count(&self) -> usize
Trait Implementations§
impl Eq for Hash
impl StructuralPartialEq for Hash
Auto Trait Implementations§
impl Freeze for Hash
impl RefUnwindSafe for Hash
impl Send for Hash
impl Sync for Hash
impl Unpin for Hash
impl UnsafeUnpin for Hash
impl UnwindSafe for Hash
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more