Skip to main content

Storage

Trait Storage 

Source
pub trait Storage: Send + Sync {
Show 14 methods // Required methods fn init(&self, vector_dimension: usize) -> Result<()>; fn get_document(&self, doc_id: &str) -> Result<Option<Document>>; fn list_documents(&self) -> Result<Vec<Document>>; fn get_document_paths( &self, doc_ids: &[String], ) -> Result<HashMap<String, String>>; fn get_chunks(&self, chunk_ids: &[String]) -> Result<Vec<Chunk>>; fn search_vectors( &self, embedding: &[f32], top_k: usize, ) -> Result<Vec<(String, f32)>>; fn search_text( &self, query: &str, top_k: usize, ) -> Result<Vec<(String, f32)>>; fn get_model_version(&self, role: ModelRole) -> Result<Option<ModelSpec>>; fn set_model_version_atomic( &self, role: ModelRole, version: &ModelSpec, ) -> Result<()>; fn get_meta(&self, key: &str) -> Result<Option<String>>; fn set_meta_atomic(&self, key: &str, value: &str) -> Result<()>; fn list_collections(&self) -> Result<Vec<Collection>>; fn count_chunks(&self) -> Result<usize>; fn begin_tx(&self) -> Result<Box<dyn StorageTx + '_>>;
}

Required Methods§

Source

fn init(&self, vector_dimension: usize) -> Result<()>

Initialize all storage tables. Pass 0 to skip creating the vector table when no embedder is available yet.

Source

fn get_document(&self, doc_id: &str) -> Result<Option<Document>>

Source

fn list_documents(&self) -> Result<Vec<Document>>

Source

fn get_document_paths( &self, doc_ids: &[String], ) -> Result<HashMap<String, String>>

Source

fn get_chunks(&self, chunk_ids: &[String]) -> Result<Vec<Chunk>>

Source

fn search_vectors( &self, embedding: &[f32], top_k: usize, ) -> Result<Vec<(String, f32)>>

Source

fn search_text(&self, query: &str, top_k: usize) -> Result<Vec<(String, f32)>>

Source

fn get_model_version(&self, role: ModelRole) -> Result<Option<ModelSpec>>

Source

fn set_model_version_atomic( &self, role: ModelRole, version: &ModelSpec, ) -> Result<()>

Source

fn get_meta(&self, key: &str) -> Result<Option<String>>

Source

fn set_meta_atomic(&self, key: &str, value: &str) -> Result<()>

Source

fn list_collections(&self) -> Result<Vec<Collection>>

Source

fn count_chunks(&self) -> Result<usize>

Source

fn begin_tx(&self) -> Result<Box<dyn StorageTx + '_>>

Begin a write transaction covering documents / chunks / vec_chunks / fts_chunks / model_versions. Operations on the returned StorageTx are atomic: they either all commit via StorageTx::commit or all roll back when the transaction is dropped without committing.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§