Struct img_hash::ImageHash [−][src]
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]
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]
encoded_hash: &str
) -> Result<ImageHash<B>, InvalidBytesError>
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> StructuralEq for ImageHash<B>
[src]
impl<B> StructuralEq for ImageHash<B>
[src]impl<B> StructuralPartialEq 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> RefUnwindSafe for ImageHash<B> where
B: RefUnwindSafe,
impl<B> UnwindSafe for ImageHash<B> where
B: UnwindSafe,
impl<B> UnwindSafe for ImageHash<B> where
B: UnwindSafe,