Skip to main content

CorpusIndex

Trait CorpusIndex 

Source
pub trait CorpusIndex {
    // Required methods
    fn search(
        &self,
        payload: &Payload,
        technique: StegoTechnique,
        max_results: usize,
    ) -> Result<Vec<CorpusEntry>, CorpusError>;
    fn add_to_index(&self, path: &Path) -> Result<CorpusEntry, CorpusError>;
    fn build_index(&self, corpus_dir: &Path) -> Result<usize, CorpusError>;
    fn search_for_model(
        &self,
        payload: &Payload,
        model_id: &str,
        resolution: (u32, u32),
        max_results: usize,
    ) -> Result<Vec<CorpusEntry>, CorpusError>;
    fn model_stats(&self) -> Vec<(SpectralKey, usize)>;
}
Expand description

Corpus index and zero-modification cover selection port.

Required Methods§

Source

fn search( &self, payload: &Payload, technique: StegoTechnique, max_results: usize, ) -> Result<Vec<CorpusEntry>, CorpusError>

Search the index for covers whose natural bit pattern already encodes (or closely encodes) payload using technique.

Returns up to max_results entries sorted by match quality.

§Errors

Returns crate::domain::errors::CorpusError::NoSuitableCover or crate::domain::errors::CorpusError::IndexError.

Source

fn add_to_index(&self, path: &Path) -> Result<CorpusEntry, CorpusError>

Add the file at path to the index, computing its bit-pattern fingerprint.

§Errors

Returns crate::domain::errors::CorpusError::AddFailed.

Source

fn build_index(&self, corpus_dir: &Path) -> Result<usize, CorpusError>

Scan corpus_dir recursively and build the full index.

Returns the number of entries indexed.

§Errors

Returns crate::domain::errors::CorpusError::IndexError.

Source

fn search_for_model( &self, payload: &Payload, model_id: &str, resolution: (u32, u32), max_results: usize, ) -> Result<Vec<CorpusEntry>, CorpusError>

Search the index for covers that match payload and have a spectral_key whose model_id and resolution match the supplied values.

Returns up to max_results entries sorted by match quality.

§Errors

Returns crate::domain::errors::CorpusError::NoSuitableCover or crate::domain::errors::CorpusError::IndexError.

Source

fn model_stats(&self) -> Vec<(SpectralKey, usize)>

Return a sorted list of (SpectralKey, count) pairs describing how many corpus entries are indexed per model/resolution combination.

Using Vec instead of HashMap to keep the trait object-safe.

Implementors§