2019-05-07 18:11:22 +08:00
|
|
|
use std::error::Error;
|
|
|
|
use fst::Set;
|
|
|
|
use sdset::SetBuf;
|
|
|
|
use crate::DocIndex;
|
|
|
|
|
|
|
|
pub trait Store {
|
|
|
|
type Error: Error;
|
|
|
|
|
|
|
|
fn words(&self) -> Result<&Set, Self::Error>;
|
|
|
|
fn word_indexes(&self, word: &[u8]) -> Result<Option<SetBuf<DocIndex>>, Self::Error>;
|
2019-06-13 22:20:01 +08:00
|
|
|
|
|
|
|
fn synonyms(&self) -> Result<&Set, Self::Error>;
|
|
|
|
fn alternatives_to(&self, word: &[u8]) -> Result<Option<Set>, Self::Error>;
|
2019-05-07 18:11:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<T> Store for &'_ T where T: Store {
|
|
|
|
type Error = T::Error;
|
|
|
|
|
|
|
|
fn words(&self) -> Result<&Set, Self::Error> {
|
|
|
|
(*self).words()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn word_indexes(&self, word: &[u8]) -> Result<Option<SetBuf<DocIndex>>, Self::Error> {
|
|
|
|
(*self).word_indexes(word)
|
|
|
|
}
|
2019-06-13 22:20:01 +08:00
|
|
|
|
|
|
|
fn synonyms(&self) -> Result<&Set, Self::Error> {
|
|
|
|
(*self).synonyms()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn alternatives_to(&self, word: &[u8]) -> Result<Option<Set>, Self::Error> {
|
|
|
|
(*self).alternatives_to(word)
|
|
|
|
}
|
2019-05-07 18:11:22 +08:00
|
|
|
}
|