pub struct StorageFactory;Expand description
Storage factory for creating different storage backends
Implementations§
Source§impl StorageFactory
impl StorageFactory
Sourcepub fn create_memory() -> Box<dyn DocumentStorage>
pub fn create_memory() -> Box<dyn DocumentStorage>
Create in-memory storage. Ephemeral — chunks + vectors live only for the process lifetime. Intended for tests and OSS quick-start.
Sourcepub fn create_file(path: &str) -> Result<Box<dyn DocumentStorage>>
pub fn create_file(path: &str) -> Result<Box<dyn DocumentStorage>>
Create file-backed storage that persists chunks + vectors to a JSON
snapshot inside path/. Closes the “RAG forgets everything on
restart” half of #669 — embeddings survive process restarts now.
Layout:
<path>/storage.json — single-file snapshot (atomic write via tmp)
Tradeoff: rewrites the whole snapshot on every store_chunks call.
Fine for thousand-chunk-scale corpora that fit in RAM (the
embedded RAG use case); a real vector database is a better fit
for million-chunk catalogs — see create_vector_db below.
Sourcepub fn create_database(
connection_string: &str,
) -> Result<Box<dyn DocumentStorage>>
pub fn create_database( connection_string: &str, ) -> Result<Box<dyn DocumentStorage>>
Create database storage. Not yet implemented — the connection string would route to a sqlx-backed implementation. Returns a labelled in-memory store for now and warns rather than failing silently. Tracked in #669 follow-up.
Sourcepub fn create_vector_db(
config: HashMap<String, String>,
) -> Result<Box<dyn DocumentStorage>>
pub fn create_vector_db( config: HashMap<String, String>, ) -> Result<Box<dyn DocumentStorage>>
Create vector-database storage. Real vector-DB integrations (Qdrant, LanceDB, pgvector) belong behind crate feature flags so the heavy client/transitive deps don’t land in every consumer. Until one of those features is enabled, this returns a clear error rather than silently falling back to ephemeral memory — the silent fallback was exactly what the audit (#669) flagged.