GeneratorType

Trait GeneratorType 

Source
pub trait GeneratorType {
    type Output: FuzzyHashType;

    const IS_CHECKSUM_EFFECTIVE: bool;
    const MIN: u32;
    const MIN_CONSERVATIVE: u32;
    const MAX: u32;

    // Required methods
    fn processed_len(&self) -> Option<u32>;
    fn update(&mut self, data: &[u8]);
    fn finalize_with_options(
        &self,
        options: GeneratorOptions,
    ) -> Result<Self::Output, GeneratorError>;

    // Provided method
    fn finalize(&self) -> Result<Self::Output, GeneratorError> { ... }
}
Expand description

The trait to represent a fuzzy hash generator.

This trait is implemented by Generator.

Required Associated Constants§

Source

const IS_CHECKSUM_EFFECTIVE: bool

Whether the checksum is updated by this generator type.

If this type is false, the resulting fuzzy hash from this generator will have checksum part with all zeroes.

In the official TLSH implementation, it is always true except multi-threaded and private modes. This crate currently does not support those modes but will be implemented in the future.

Source

const MIN: u32

The minimum data length (on all modes).

Source

const MIN_CONSERVATIVE: u32

The minimum data length (on the conservative mode).

Source

const MAX: u32

The maximum data length (inclusive).

Required Associated Types§

Source

type Output: FuzzyHashType

The output type.

Required Methods§

Source

fn processed_len(&self) -> Option<u32>

Returns the data length it processed.

If the generator is unable to represent exact data length it processed, it returns None. Otherwise, the exact data length is returned by Some.

Source

fn update(&mut self, data: &[u8])

Update the generator by feeding data to it.

Source

fn finalize_with_options( &self, options: GeneratorOptions, ) -> Result<Self::Output, GeneratorError>

Finalize the fuzzy hash with specified options.

You will likely use the default options and use finalize() instead.

Provided Methods§

Source

fn finalize(&self) -> Result<Self::Output, GeneratorError>

Finalize the fuzzy hash with the default options.

If you want to use a custom generator options, use finalize_with_options() instead.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T: ConstrainedFuzzyHashType> GeneratorType for Generator<T>

Source§

const IS_CHECKSUM_EFFECTIVE: bool = <<<T as ConstrainedFuzzyHashType>::Params as ConstrainedFuzzyHashParams>::InnerGeneratorType>::IS_CHECKSUM_EFFECTIVE

Source§

const MIN: u32 = <<<T as ConstrainedFuzzyHashType>::Params as ConstrainedFuzzyHashParams>::InnerGeneratorType>::MIN

Source§

const MIN_CONSERVATIVE: u32 = <<<T as ConstrainedFuzzyHashType>::Params as ConstrainedFuzzyHashParams>::InnerGeneratorType>::MIN_CONSERVATIVE

Source§

const MAX: u32 = <<<T as ConstrainedFuzzyHashType>::Params as ConstrainedFuzzyHashParams>::InnerGeneratorType>::MAX

Source§

type Output = T