pub trait Provider<'a> {
    type DocumentIter: Iterator<Item = Id> + ExactSizeIterator + 'a;
    type WordIter: Iterator<Item = &'a Arc<Alphanumeral<StrPtr>>> + 'a;
    type WordFilteredIter: Iterator<Item = &'a Arc<Alphanumeral<StrPtr>>> + 'a;

    // Required methods
    fn insert_word(&mut self, word: impl AsRef<str>, document: Id, index: usize);
    fn remove_document(&mut self, document: Id);
    fn contains_word(&self, word: impl AsRef<str>, document: Id) -> bool;
    fn documents_with_word(
        &'a self,
        word: impl AsRef<str>
    ) -> Option<Self::DocumentIter>;
    fn size(&self) -> usize;
    fn word_count_upper_limit(&self) -> usize;
    fn word_count_limit(&self) -> usize;
    fn words(&'a self) -> Self::WordIter;
    fn words_starting_with(&'a self, c: char) -> Self::WordFilteredIter;
    fn word_proximity_threshold(&self) -> f32;
    fn word_proximity_algorithm(&self) -> Algorithm;

    // Provided method
    fn digest_document(&mut self, id: Id, content: &str) { ... }
}
Expand description

Allows to insert words and remove occurrences from documents.

Required Associated Types§

Required Methods§

source

fn insert_word(&mut self, word: impl AsRef<str>, document: Id, index: usize)

The implementation should convert word to lower-case and remove any hyphen -.

Alphanumeral can be used for this purpose.

source

fn remove_document(&mut self, document: Id)

Removes all registered occurrences of document from all words.

source

fn contains_word(&self, word: impl AsRef<str>, document: Id) -> bool

If document contains at least one occurrence of word.

source

fn documents_with_word( &'a self, word: impl AsRef<str> ) -> Option<Self::DocumentIter>

source

fn size(&self) -> usize

Estimate of the number of bytes this index uses in memory, specifically the heap.

This assumes you’re on a 64-bit architecture. Else, you can expect the size to be half, as most of what’s stored in an index is pointers to data.

This should not be relied on. Rather, it’s a hint.

source

fn word_count_upper_limit(&self) -> usize

source

fn word_count_limit(&self) -> usize

source

fn words(&'a self) -> Self::WordIter

source

fn words_starting_with(&'a self, c: char) -> Self::WordFilteredIter

source

fn word_proximity_threshold(&self) -> f32

source

fn word_proximity_algorithm(&self) -> Algorithm

Provided Methods§

source

fn digest_document(&mut self, id: Id, content: &str)

Only adds words which are alphanumeric.

Implementors§