use crate::guardian::error::GuardianError;
use crate::log::{Log, entry::Entry};
use crate::traits::StoreIndex;
pub struct NoopIndex;
pub fn new_noop_index(
_public_key: &[u8],
) -> Box<dyn StoreIndex<Error = GuardianError> + Send + Sync> {
Box::new(NoopIndex)
}
impl StoreIndex for NoopIndex {
type Error = GuardianError;
fn contains_key(&self, _key: &str) -> std::result::Result<bool, Self::Error> {
Ok(false)
}
fn get_bytes(&self, _key: &str) -> std::result::Result<Option<Vec<u8>>, Self::Error> {
Ok(None)
}
fn keys(&self) -> std::result::Result<Vec<String>, Self::Error> {
Ok(Vec::new())
}
fn len(&self) -> std::result::Result<usize, Self::Error> {
Ok(0)
}
fn is_empty(&self) -> std::result::Result<bool, Self::Error> {
Ok(true)
}
fn update_index(
&mut self,
_oplog: &Log,
_entries: &[Entry],
) -> std::result::Result<(), Self::Error> {
Ok(())
}
fn clear(&mut self) -> std::result::Result<(), Self::Error> {
Ok(())
}
}