pub struct FuzzyHashLengthEncoding { /* private fields */ }Expand description
Approximated input data length encoded as 8-bits in a fuzzy hash.
On TLSH, it compresses a 32-bit input size to an approximated encoding of 8-bits. This enables to distinguish statistically similar files with large differences in the size.
This struct can have a:
- A valid encoding for a valid input size,
- A “valid” encoding for an invalid input size (only appears when the input is smaller than the TLSH’s lower limit), or
- An invalid encoding (does not correspond any of the 32-bit size).
This struct only handles the validness of its encoding. So, the case 2 above is considered “valid” in this type.
Implementations§
Source§impl FuzzyHashLengthEncoding
impl FuzzyHashLengthEncoding
Sourcepub const MAX_DISTANCE: u32 = 1_536u32
pub const MAX_DISTANCE: u32 = 1_536u32
The maximum distance between two length encodings.
Sourcepub fn new(len: u32) -> Option<Self>
pub fn new(len: u32) -> Option<Self>
Encode the 32-bit data length as rough 8-bit representation.
Sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Returns whether the encoding is valid.
Note that, if the encoding only appears when the input size is too
small, it also returns true because the encoding itself is still
valid. On the other hand, if the encoding exceeds the upper limit, it
will return false because it will not correspond to any of 32-bit
input size.
Sourcepub fn compare(&self, other: &FuzzyHashLengthEncoding) -> u32
pub fn compare(&self, other: &FuzzyHashLengthEncoding) -> u32
Compare against another length encoding and return the distance between them.
Trait Implementations§
Source§impl Clone for FuzzyHashLengthEncoding
impl Clone for FuzzyHashLengthEncoding
Source§fn clone(&self) -> FuzzyHashLengthEncoding
fn clone(&self) -> FuzzyHashLengthEncoding
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more