pub trait Storage: Send + Sync {
Show 15 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 get_existing_chunk_ids(
&self,
chunk_ids: &[String],
) -> Result<Vec<String>>;
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§
Sourcefn init(&self, vector_dimension: usize) -> Result<()>
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.
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>>
Sourcefn get_existing_chunk_ids(&self, chunk_ids: &[String]) -> Result<Vec<String>>
fn get_existing_chunk_ids(&self, chunk_ids: &[String]) -> Result<Vec<String>>
Which of the given chunk ids are already stored. Used by the indexer to skip re-embedding shared chunks (identical text hashed to the same id).
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>
Sourcefn begin_tx(&self) -> Result<Box<dyn StorageTx + '_>>
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".