Struct img_hash::ImageHash[][src]

pub struct ImageHash<B = Box<[u8]>> { /* fields omitted */ }

A struct representing an image processed by a perceptual hash. For efficiency, does not retain a copy of the image data after hashing.

Get an instance with ImageHash::hash().

Implementations

impl<B: HashBytes> ImageHash<B>[src]

pub fn as_bytes(&self) -> &[u8][src]

Get the bytes of this hash.

pub fn from_bytes(bytes: &[u8]) -> Result<ImageHash<B>, InvalidBytesError>[src]

Create an ImageHash instance from the given bytes.

Errors:

Returns a InvalidBytesError::BytesWrongLength error if the slice passed can’t fit in B.

pub fn dist(&self, other: &Self) -> u32[src]

Calculate the Hamming distance between this and other.

Equivalent to counting the 1-bits of the XOR of the two hashes.

Essential to determining the perceived difference between self and other.

Note

This return value is meaningless if these two hashes are from different hash sizes or algorithms.

pub fn from_base64(
    encoded_hash: &str
) -> Result<ImageHash<B>, InvalidBytesError>
[src]

Create an ImageHash instance from the given Base64-encoded string.

Errors:

Returns InvaidBytesError::Base64(DecodeError::InvalidLength) if the string wasn’t valid base64. Otherwise returns the same errors as from_bytes`.

pub fn to_base64(&self) -> String[src]

Get a Base64 string representing the bits of this hash.

Mostly for printing convenience.

Trait Implementations

impl<B: Clone> Clone for ImageHash<B>[src]

impl<B: Debug> Debug for ImageHash<B>[src]

impl<B: Eq> Eq for ImageHash<B>[src]

impl<B: Hash> Hash for ImageHash<B>[src]

impl<B: PartialEq> PartialEq<ImageHash<B>> for ImageHash<B>[src]

impl<B> StructuralEq for ImageHash<B>[src]

impl<B> StructuralPartialEq for ImageHash<B>[src]

Auto Trait Implementations

impl<B> RefUnwindSafe for ImageHash<B> where
    B: RefUnwindSafe

impl<B> Send for ImageHash<B> where
    B: Send

impl<B> Sync for ImageHash<B> where
    B: Sync

impl<B> Unpin for ImageHash<B> where
    B: Unpin

impl<B> UnwindSafe for ImageHash<B> where
    B: UnwindSafe

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> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.