[][src]Struct fuzzyhash::FuzzyHash

pub struct FuzzyHash { /* fields omitted */ }

Hasher for fuzzy algorithm

Implementations

impl FuzzyHash[src]

pub fn new<S: AsRef<[u8]>>(input: S) -> Self[src]

Construct a new FuzzyHash from source data

Example

use std::fs::read;
use std::io::Read;
use fuzzyhash::FuzzyHash;

let mut data = read("/usr/bin/bash").unwrap();
let mut fuzzy_hash = FuzzyHash::new(data);

pub fn file<P: AsRef<Path>>(path: P) -> Result<Self, Error>[src]

Hash a file pointed to by path.

Example

use fuzzyhash::{FuzzyHash};
let hash = FuzzyHash::file("/home/me/a_large_file.bin").unwrap();

pub fn read<R: Read>(reader: &mut R) -> Result<Self, Error>[src]

Hash target implementing std::io::Read

Example

use fuzzyhash::FuzzyHash;
use std::io::{Cursor, Read};

let mut cursor = Cursor::new(vec![1,2,3,4,5,6,7,8,9,10]);
let fuzzy = FuzzyHash::read(&mut cursor);

pub fn update<S: AsRef<[u8]>>(&mut self, input: S)[src]

Add chunk to the data source

pub fn finalize(&mut self)[src]

Called to finalize the hashing and generate a string value

pub fn compare<S: AsRef<str>, T: AsRef<str>>(first: S, second: T) -> Result<u32>[src]

Compare two fuzzy hashes

Arguments

  • first - first fuzzy hash to compare
  • second - second fuzzy hash to compare

Example

use fuzzyhash::FuzzyHash;
assert_eq!(FuzzyHash::compare(
           "96:U57GjXnLt9co6pZwvLhJluvrszNgMFwO6MFG8SvkpjTWf:Hj3BeoEcNJ0TspgIG8SvkpjTg",
           "96:U57GjXnLt9co6pZwvLhJluvrs1eRTxYARdEallia:Hj3BeoEcNJ0TsI9xYeia3R").unwrap(),
    63);

pub fn compare_to(&self, other: &FuzzyHash) -> Option<u32>[src]

Compare this fuzzy hash against another

Arguments

  • other - compare this fuzzy hash to other

Example

use fuzzyhash::FuzzyHash;
let mut fuzzy_hash = FuzzyHash::new("some data to hash for the purposes of running a test");
assert_eq!(fuzzy_hash.compare_to(
           &"3:HEREar5MFUul0U0KMP:knl8lkKMP".into()),
           Some(18));

Trait Implementations

impl Default for FuzzyHash[src]

impl Display for FuzzyHash[src]

impl From<&'_ str> for FuzzyHash[src]

impl From<String> for FuzzyHash[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.