use crate::posting::Posting;
pub trait FtsBackend {
type Error: std::fmt::Display;
fn read_postings(&self, collection: &str, term: &str) -> Result<Vec<Posting>, Self::Error>;
fn write_postings(
&self,
collection: &str,
term: &str,
postings: &[Posting],
) -> Result<(), Self::Error>;
fn remove_postings(&self, collection: &str, term: &str) -> Result<(), Self::Error>;
fn read_doc_length(&self, collection: &str, doc_id: &str) -> Result<Option<u32>, Self::Error>;
fn write_doc_length(
&self,
collection: &str,
doc_id: &str,
length: u32,
) -> Result<(), Self::Error>;
fn remove_doc_length(&self, collection: &str, doc_id: &str) -> Result<(), Self::Error>;
fn collection_terms(&self, collection: &str) -> Result<Vec<String>, Self::Error>;
fn collection_stats(&self, collection: &str) -> Result<(u32, u64), Self::Error>;
fn increment_stats(&self, collection: &str, doc_len: u32) -> Result<(), Self::Error>;
fn decrement_stats(&self, collection: &str, doc_len: u32) -> Result<(), Self::Error>;
fn read_meta(&self, key: &str) -> Result<Option<Vec<u8>>, Self::Error>;
fn write_meta(&self, key: &str, value: &[u8]) -> Result<(), Self::Error>;
fn write_segment(&self, key: &str, data: &[u8]) -> Result<(), Self::Error>;
fn read_segment(&self, key: &str) -> Result<Option<Vec<u8>>, Self::Error>;
fn list_segments(&self, collection: &str) -> Result<Vec<String>, Self::Error>;
fn remove_segment(&self, key: &str) -> Result<(), Self::Error>;
fn purge_collection(&self, collection: &str) -> Result<usize, Self::Error>;
}