use std::collections::HashMap;
use crate::{
embed::Embedder,
error::Result,
vector_store::{ChunkSearchResult, VecInfo},
};
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct Document {
pub id: i64,
pub title: String,
pub body: String,
pub path: String,
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct SearchResult {
pub id: i64,
pub title: String,
pub path: String,
pub score: f64,
}
pub trait RetrieveStore: Send + Sync {
fn file_mtimes(&self) -> Result<HashMap<String, i64>>;
fn upsert_file(&self, path: &str, mtime: i64) -> Result<()>;
fn remove_file(&self, path: &str) -> Result<()>;
fn file_count(&self) -> Result<u64>;
fn upsert_document(&self, doc: &Document) -> Result<()>;
fn remove_document(&self, id: i64) -> Result<()>;
fn rebuild_fts(&self) -> Result<()>;
fn search_fts(&self, query: &str, limit: usize) -> Result<Vec<SearchResult>>;
fn document_ids(&self) -> Result<Vec<i64>>;
fn document_count(&self) -> Result<u64>;
fn embed_pending(
&self,
embedder: &dyn Embedder,
on_progress: &dyn Fn(usize, usize),
) -> Result<usize>;
fn vec_info(&self) -> Result<VecInfo>;
fn search_similar(&self, query_vec: &[f32], limit: usize) -> Result<Vec<ChunkSearchResult>>;
}